Search code examples
androidlauncher

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 ?


Solution

  • 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.