Linux‎ > ‎

Android

Detecting Debug at Compile-Time

Often I find if want to exclude code if the application is not compiled with debugging enabled.  This can be achieved with the flag "BuildConfig.DEBUG"

if (BuildConfig.DEBUG)
{
    // do something in debug only
    Log.d(TAG, "Text");
}

Icon Sizes

Display Size
 LDPI  36px * 36px 
 MDPI  48px * 48px 
 HDPI  72px * 72px 
 XHDPI  96px * 96px 
 XHDPI  144px * 144px 
 WEB 512px * 512px 

Note : WEB(512 x 512) image is used when you upload your android application on Market

Prevent the keyboard popping up on starting an activity

This works by making the parent layout for the activity focusable. So the child elements don't automatically get the focus, the parent does.
Add the following to the parent layout for the activity

android:focusable="true"
android:focusableInTouchMode="true"

Lock the screen orientation

In the manifest file, set the following for each activity that you need the orientation locked

android:screenOrientation="portrait




Subpages (2): ADP1 Using NFC