1

Although I have been searching on Stack Overflow for quite some time, did not find the answer I want so far.

1. Problem description:

  • I have an Android app with bunch of activities and submitted to Google Play. After it's published, I downloaded it, whenever open the app, it starts a new task. I need to click the hardware back button several times to kill all the tasks. While, after that, whenever I launch the app again, everything is fine.
  • Another weird thing is that there's no problem if I directly install the app on the device through adb command (adb install xxxx.apk)

2. What I did:

  • originally, in the code, I was using the "standard" launch mode for the launch activity. I encountered the problem as described above.
  • after I read the official document, I realized that "standard" mode will launch an instance of the activity everytime, so I changed the launch mode to be "singtop", but the problem is still there.

3. What I do not understand:

  • Why the app keeps creating new task if I install the app from Google Play. Why "Singtop" launch mode does not work in this case?
  • why I do not have the problem when install the app directly through adb command, while I get the problem when install app from Google Play. What's the difference.

4. Source code for reference:

  • build.gradle (Module:app):

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"
    
        defaultConfig {
            applicationId "com.example.testing.exampletesting"
            minSdkVersion 17
            targetSdkVersion 22
        }
    
        buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.1.0'
    }
    
  • AndroidManifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.testing.exampletesting"
        android:versionCode="10"
        android:versionName="1.0.1" >
    
    <application
        android:allowBackup="true"
        android:icon="@mipmap/app_logo"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".LaunchActivity"
            android:launchMode="standard">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    
        <activity android:name=".DummyAActivity" />
    
        <activity android:name=".DummyBActivity" />
    
        <activity android:name=".DummyCActivity" />
    
    </application>
    
    </manifest>
    
halfer
  • 19,824
  • 17
  • 99
  • 186
SamChan
  • 95
  • 1
  • 5
  • I don't think this is a launch mode issue. You might be starting same activity a lot of times. Your app's flow should be aligned in that case. – Keshav Jan 10 '16 at 18:56
  • You are seeing this nasty Android bug: http://stackoverflow.com/a/16447508/769265 – David Wasser Dec 28 '16 at 15:27

0 Answers0