Monthly Archives: June 2013

[Android] The very first point to get width/height in activity life-cycle

No need to say much, read the code and find out thing.


@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); Log.e(“Height”, ” >> ” + mParentView.getMeasuredHeight()); Log.e(“Width”, ” >> ” + mParentView.getMeasuredWidth()); }


[Android-JSON] Avoid No value exception when service does not return a specific value in json reponse

Normal way to get string value from a json object would be :


well, sometimes this way does not fit. When you don’t know for sure that your service you are requesting is always stable. It may not return some keys for you, and oops you got 

JSONException No value for “missing key”

Here we may need help from other options.

optString(KEY) AND optString(KEY, Fallback_value)


[Android-ADT] Can not generate R file after update to ADT 22.

Don’t worry , Stackoverflow is always beside you.
– Open SDK manager.

– Install something called Android SDK Build-tools.

– Restart  Eclipse.
– Enjoy.