Application to install as Launcher

What I did: I created a custom launcher that actually launches / sets as the startup launcher at boot. It also appears in the list of installed launchers, which means that so far so good.

What I want: But when I launch / install my application as a launch and press the "Back" button, it goes to the previously installed launch screen.
That should not be so, I think. It must remain installed as the home / standard launcher of the device.

My code addition:
In my manifest, I added the 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?

+5
source share
2 answers

Of course, you can intercept the BACK button in your activity by overriding onBackPressed() and prevent it from being destroyed just by not binding to the superclass.

+3
source

Override 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; } } 
0
source

Source: https://habr.com/ru/post/1206241/


All Articles