Launcher app and home key incompatible

I am creating a launcher application with many actions. I want the home button to always return the user to mainActivity when the home key is pressed and my application is installed as the default launcher. This works in 90% of cases, but after a while the home key stops working. It registers a click on the user, but no longer returns them to mainactivity. What makes it shy away from me. For several months we tried to recreate the error with a certain sequence, but to no avail. We cannot understand what makes it stop working. Below is my manifest. I am wondering if I am missing a flag or something else.

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sapientnitro.lcinstore2" android:configChanges="keyboard|uiMode" android:versionCode="4" android:versionName="4.0" > <uses-sdk android:minSdkVersion="15" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-feature android:name="android.hardware.camera" /> <application android:icon="@drawable/icon" android:label="@string/app_name" > <activity android:name=".activities.LCInStore2Activity" android:alwaysRetainTaskState="true" android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".activities.MainActivity" android:configChanges="keyboard|uiMode" android:label="Main" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.MAINACTIVITY" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.Authenticate" android:label="Authenticate" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.AUTHENTICATE" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.Settings" android:label="Settings" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.SETTINGS" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.CustomerHome" android:label="CustomerHome" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.CUSTOMERHOME" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.CustomWebView" android:label="CustomWebView" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.CUSTOMWEBVIEW" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.CustomCamera" android:label="CustomCamera" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.CUSTOMCAMERA" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.FavoritesCustomer" android:label="FavoritesCustomer" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.FAVORITESCUSTOMER" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.FavoritesAssociate" android:label="FavoritesAssociate" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.FAVORITESASSOCIATE" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.Browser" android:hardwareAccelerated="true" android:label="Browser" android:screenOrientation="landscape" > <!-- android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> --> <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.BROWSER" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.VideoViewer" android:label="Video Viewer" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.VIDEOVIEWER" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.GalleryOneUp" android:label="GalleryOneUp" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.GALLERYONEUP" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.GalleryFourUp" android:label="GalleryFourUp" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.GALLERYFOURUP" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.GeneralRx" android:focusable="true" android:focusableInTouchMode="true" android:label="GeneralRx" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateHidden" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.GeneralRX" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.SunglassRx" android:focusable="true" android:focusableInTouchMode="true" android:label="SunglassRx" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateHidden" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.SunglassRX" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.ComputerRx" android:focusable="true" android:focusableInTouchMode="true" android:label="ComputerRx" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateHidden" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.ComputerRX" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.NightGlassesRx" android:focusable="true" android:focusableInTouchMode="true" android:label="NightGlassesRx" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateHidden" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.NightGlassesRX" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.ActiveRx" android:focusable="true" android:focusableInTouchMode="true" android:label="ActiveRx" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateHidden" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.ActiveRX" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.SafetyRx" android:focusable="true" android:focusableInTouchMode="true" android:label="SafetyRx" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateHidden" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.SafetyRx" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.ContactRx" android:focusable="true" android:focusableInTouchMode="true" android:label="ContactRx" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateHidden" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.ContactRx" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.SettingsRx" android:focusable="true" android:focusableInTouchMode="true" android:label="SettingsRx" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateHidden" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.SettingsRX" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <receiver android:name=".SettingsReceiver" > </receiver> <activity android:name=".activities.CEETraining" android:label="@string/title_activity_ceetraining" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.CeeTraining" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.BrandTraining" android:label="@string/title_activity_brand_training" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.BrandTraining" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.LensTraining" android:label="@string/title_activity_lens_training" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.LensTraining" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.MakeAbility" android:label="@string/title_activity_makeability" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.Makeability" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <activity android:name=".activities.MakeabilityResults" android:label="@string/title_activity_makeability_results" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter> <action android:name="com.sapientnitro.lcinstore2.activities.Makeabilityresults" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> </manifest> 
+4
source share
1 answer

I believe that the problem you are facing can be solved by making the main activity of replacing the house with one task.

To do this, you add the following line to your manifest as part of the main action: launchMode="singleTask" description of what this can be found here .

Now that your application receives a home press and the application does not work, it will launch a new instance with onCreate . If the application is already running in the foreground or in a paused state, onNewIntent will be called in your main action and it will be brought to the foreground.

+4
source

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


All Articles