Noman
Noman

Reputation: 4109

App to set as Launcher

What i had done: I have made a custom launcher that actually runs/sets as a home screen launcher upon load. Also it appears in the installed launchers list, which means everything is good so far.

What i want: But, when i launch/set my application as launcher and press back button, it goes to the previously set launcher screen.
It should not be like this i guess. It shall remain set like a home/default launcher of the device.

My Code Additions:
In my manifest i added following:

 <activity
        android:name=".Main"
        android:launchMode="singleTask"
        android:clearTaskOnLaunch="true"
        android:stateNotNeeded="true"
        android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>

            <!-- These two lines are setting it as a launcher-->
            <category android:name="android.intent.category.HOME"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>  

Any idea how i can achieve my goal ?

Upvotes: 7

Views: 5593

Answers (2)

Arjun Komath
Arjun Komath

Reputation: 2852

Override the onKeyDown(), so that it doesn't do anything.

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            //do nothing!
            return true;
        }
    }

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007584

You are certainly welcome to intercept the BACK button in your activity, by overriding onBackPressed(), and preventing it from destroying the activity by simply not chaining to the superclass.

Upvotes: 5

Related Questions