Activity / application launched from NFC never appears in the list of recent applications

I am developing an application designed for ICS + phones.

In the application, I have a Splash screen and a few more screens that can be launched from the Splash screen or using NFC touch. One of my actions contains the following intent filter:

<intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="application/com.myapp.thing.android.beam.ip" /> </intent-filter> 

For some reason, I cannot understand that whenever an action containing the specified intent filter is triggered, the activity does not appear in the Recent Applications list when the user clicks the Home button. Through the debugger, I checked that it is not destroyed, it just stopped.

If the Splash screen was opened before ThingActivity, Splash will be displayed in the list of recent applications, even if it was not the main activity when you click the Home button. By clicking "Splash" in the "Recent Applications" list, you will see a splash, not the activity that was previously on top. Any activity on top of the Splash screen seems to be "lost", even though streams and receivers are still running in bg.

The stranger behavior is that this behavior also applies to any activity triggered from an activity containing an NFC intent filter, or any activity triggered from these actions, etc.

If I remove the intent filter, this behavior disappears, and any activity was on top, ALWAYS appear in the list of recent applications, but will be broken, because NFC is the main function.

My complete manifest is as follows:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myapp.thing" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" /> <!-- Permission required to use the TCP transport --> <uses-permission android:name="android.permission.INTERNET" > </uses-permission> <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" > </uses-permission> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" > </uses-permission> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" > </uses-permission> <!-- Permission required to use the Bluetooth transport --> <uses-permission android:name="android.permission.BLUETOOTH" > </uses-permission> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" > </uses-permission> <uses-permission android:name="android.permission.BROADCAST_STICKY" > </uses-permission> <uses-permission android:name="android.permission.NFC" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" > </uses-permission> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- RECORD_AUDIO is needed to create an audio recorder --> <uses-permission android:name="android.permission.RECORD_AUDIO" > </uses-permission> <!-- MODIFY_AUDIO_SETTINGS is needed to use audio effects such as environmental reverb --> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" > </uses-permission> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".ui.SplashActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.myapp.thing.ui.ReceiverActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/app_name" android:screenOrientation="portrait" > </activity> <activity android:name="com.myapp.thing.ui.BaseActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/app_name" android:screenOrientation="portrait" > </activity> <activity android:name="com.myapp.thing.ui.BroadcasterActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/app_name" android:screenOrientation="portrait" > </activity> <activity android:name="com.myapp.thing.ui.ChooseFileActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/app_name" android:screenOrientation="portrait" > </activity> <activity android:name="com.myapp.thing.ui.ThingActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/app_name" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="application/com.myapp.thing.android.beam.ip" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SEND_MULTIPLE" /> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="audio/*" /> </intent-filter> </activity> <service android:name="com.myapp.thing.service.ThingService" android:label="ThingService" > </service> </application> 

Why does enabling this intent filter prevent my application from being on the list of recent applications?

+4
source share
1 answer

I do not understand all the described behavior, I must admit. How Android handles actions and tasks can be quite complicated. One piece of perhaps important information is that when your activity is launched using the NFC intent, it will be launched as a separate task. I suspect this is due to the behavior you are observing.

+2
source

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


All Articles