Android

Solve adb devices empty or Android not detected in Eclipse

26 Jan , 2014  

If ADB not showing your devices or Eclipse not showing your Android in running devices, probably you’re missing the USB driver. Please install the usb driver for your android devices. For samsung, you can search google for “Samsung_USB_Driver_for_Mobile_Phones_v1.5.14.0″

,

Android

Dex Loader Unable to execute dex : Multiple dex files define Android

17 Jan , 2014  

When we using 3rd party library, sometimes we got this error while running our app, eg:

1
Dex Loader Unable to execute dex : Multiple dex files define Lcom/google/gson/JsonSerializer;

This happen when in our app, we have libs folder with gson jar (eg: gson-2.2.4.jar).
In sametime, our Google Play Service library already have Gson as well.

The solution is uncheck the same libraries in our App.

Capture

Android

Pitfalls in Android

14 Jan , 2014  

1. XML using same ID attribute
2. Editor always create on new instance

1
        SharedPreferences.Editor editor = settings.edit();

Android

Implement SSL in Android

13 Jan , 2014  

Please follow this links for implement SSL in Android :

http://stackoverflow.com/questions/1217141/self-signed-ssl-acceptance-android#answer-15531475

faced this issue yesterday, while migrating our company’s RESTful API to HTTPS, but using self-signed SSL certs.

I’ve looking everywhere but all the “correct” marked answers I’ve found consisted on disabling certificate validation, clearly overriding all the sense of SSL.

I finally came to a solution.
More…

Server

Solve gitignore not working windows

13 Jan , 2014  

The solution gitignore not working windows

1
2
3
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"

For android, .gitignore can be :

1
2
3
4
gen/
bin/
project.properties
.gitignore

Android

NumberPicker looping Android

9 Jan , 2014  

Here is to make NumberPicker looping in Android :

1
2
3
4
5
6
7
final NumberPicker np1 = (NumberPicker) view
                .findViewById(R.id.numberPicker1);
final String[] nums1 = generateHour(0);
np1.setMaxValue(23);
np1.setMinValue(0);
np1.setWrapSelectorWheel(true);
np1.setDisplayedValues(nums1);

Android

Keep highlight selected item in Gridview Android

8 Jan , 2014  

Gridview have option to modify it’s selector (listSelector). When we click on item in Gridview, we saw blink blue and then dissapear after we release it.

To make it stay, all we need just declare it at “android:listSelector” in GridView XML.
For instance :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/calendar_gridview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:listSelector="@color/caldroid_sky_blue"
    android:adjustViewBounds="true"
    android:background="@color/caldroid_lighter_gray"
    android:gravity="center_horizontal"
    android:horizontalSpacing="1dp"
    android:numColumns="7"
    android:padding="1dp"
    android:stretchMode="columnWidth"
    android:verticalSpacing="1dp" />

To make selector background not overriden / set in bottom side, use “setDrawSelectorOnTop(false)” :

1
2
3
gridView = (GridView) inflater.inflate(R.layout.date_grid_fragment,
                container, false);
gridView.setDrawSelectorOnTop(false);

,