Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My launcher app starts twice when booting device

I have created a Launcher app. Everything works fine but I get errors when booting up the device. If I turn my phone off and then I turn it back on I found out that the app gets started 2 times and both of them starts about the same time. Any help about this?

I have this in the manifest:

<application       
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.testing"

        android:launchMode="singleTask"
        android:clearTaskOnLaunch="true"
        android:stateNotNeeded="true"                 

        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" /> 
            <category android:name="android.intent.category.HOME"/> 
            <category android:name="android.intent.category.DEFAULT" />                 
        </intent-filter>
    </activity>
    .....

Of course, I do NOT use any android.intent.action.BOOT_COMPLETED

After booting the phone and after having the error, my app closes. Then, if I press the Home button then it starts normally (just one instance of it) and everything works ok.

like image 240
Ton Avatar asked Apr 10 '14 20:04

Ton


1 Answers

I too had this issue. But got it fixed by changing the launch mode of the activity to singleTop.

In my case Splashscreen was the launcher. I set android:launchMode="singleTop" in manifest. But it didn't work.

After that I could see that the LoginActivity was the landing page means, the application waits for user input in that page. So I added android:launchMode="singleTop" to LoginActivity also. Now it is working.

like image 178
Akshatha Srinivas Avatar answered Oct 29 '22 08:10

Akshatha Srinivas