Why does Android launch multiple instances in singleTask or singleInstance?

What I want to achieve:

MainActivity should be reused, in other words, I do not want to run onCreate()again, but only onResume()in the same Activity, but I have strange behavior. It seems like launchModeAndroidManifest is ignored. No matter what I set ( singleTask, singleInstance), it always creates a new activity that leads to heap growth. When I exit the application with the home button and run it again, every time a new instance is created. (noticed that in the .hprof leak report).

Here's what it looks like:

<activity
    android:name="com.mydomain.myapp.pro.MainActivity"
    android:launchMode="singleTask"
    android:screenOrientation="nosensor" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

, , Activity home (onDestroy() ), . , , MainActivity, . , onDestroy() , , Activity ( ):

Leak report

, onDestroy() , finish(), . , Android, Activity, . , , finish() MainActivity onPause(). . onDestroy() super.onDestroy(), , , MainActivity.

+4
1

. - , AdMob. "Android". - . .

+1

All Articles