Home Action on Back Button

posted Apr 10, 2013, 1:42 AM by Akash Khaitan

Just use the below method which would make the back button to perform like home button of Android

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        return super.onKeyDown(keyCode, event);

Could not set the project desc for '' because project description file is out of Sync

posted Mar 14, 2013, 4:53 AM by Akash Khaitan

See the Log cat
Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead.
Please use Android Tools > Fix Project Properties.

I just followed the log cat and the syncing was successfully done

Right click on project -> Android Tools -> Fix Project Properties

Going Back Multiple Activity/Finishing Multiple Activity

posted Mar 14, 2013, 3:16 AM by Akash Khaitan   [ updated Mar 14, 2013, 3:21 AM ]

Often I used to create a new activity whenever it was required to finish multiple activity. This resulted in repetition of many activity.

Just a simple addition of line took me back to the desired activity and removed all the activities above it. Thus no repetitions of activity now

Current we are on Activity D
A -> B -> C -> D

To go to B

Intent intent = new Intent(getApplicationContext(), B.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                                //This line startActivity(intent);

Removes activities
D, C, B

Again launches activity B

Thus we have

A-> B

The connection to adb is down, and a severe error has occurred

posted Mar 14, 2013, 2:49 AM by Akash Khaitan   [ updated Mar 14, 2013, 3:08 AM ]

In Log Cat : Please ensure that adb is correctly located at '' and can be executed

Just restarted the eclipse and the error was resolved

Bitmap to Drawable

posted Mar 12, 2013, 3:01 AM by Akash Khaitan

Bitmap bm= BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);                //Some bitmap
Drawable d=new BitmapDrawable(null, bm);

No Default Proposals : Eclipse

posted Mar 12, 2013, 1:59 AM by Akash Khaitan   [ updated Mar 12, 2013, 2:00 AM ]

In Eclipse go to

Preferences->Java->Editor->Content Assist->Advanced - check Java Proposals - Apply

This enabled the proposals for me

SDK Manager : Failed to fetch URL

posted Mar 9, 2013, 12:30 AM by Akash Khaitan   [ updated Mar 9, 2013, 7:51 AM ]

I went to
Android SDK manager -> Tools -> Options

Selected in others "Force https://.............................................."

and it started working

Convert Google Market to Play

posted Mar 6, 2013, 4:12 AM by Akash Khaitan   [ updated Mar 9, 2013, 7:33 AM ]

Android Market is now part of Google Play; however, if your phone is running below Android OS version 2.2 (Froyo),
your device will not receive the update to Google Play and will remain on Android Market.


URL Encoding

posted Mar 5, 2013, 4:06 AM by Akash Khaitan   [ updated Mar 9, 2013, 7:57 AM ]

URL Encoding basically means encoding of string in http format, like replacing of spaces, &, = etc

String encodedURL = URLEncoder.encode(urlAsString, "UTF-8");
URL url = new URL(encodedURL);

Get Bitmap from Drawable

posted Mar 1, 2013, 4:03 AM by Akash Khaitan   [ updated Mar 9, 2013, 7:39 AM ]

Drawable d = Some Drawable;
Bitmap bm=((BitmapDrawable)d).getBitmap();

1-10 of 42