0

There are two activities ActivityA and ActivityB, both are made singleTask. Here ActivityB is of category HOME and it is set to always. I am starting ActivityA from a BroadcastReceiver on ACTION_BOOT_COMPLETED, it is starting ActivityA as expected but when HOME KEY is pressed (which is ActivityB), ActivityA is getting destroyed.
What can be the possible reason of it? How can I stop ActivityA from being destroyed? By keeping both activities singleTask.

This is the BroadcastReciever:

public class MyStartupIntentReceiver extends BroadcastReceiver {


@Override
public void onReceive(Context context, Intent intent) {
    if (Intent.ACTION_BOOT_COMPLETED == intent.getAction()) {

        Intent i = new Intent(context, ActivityA.class);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |       Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(i);
     }
   }
}

And manifest file is as follows:

   <activity
        android:name="ActivityB"
        android:launchMode="singleTask"
        android:screenOrientation="landscape"
        android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
        <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>

    <activity
        android:name="ActivityA"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    </activity>
Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
bala
  • 168
  • 1
  • 8
  • 1
    Any specific reason for making android:launchMode="singleTask" ?? – Virag Brahme Apr 02 '14 at 07:47
  • Yes there are some more activity which will be coming on top of these acitivies, we want to clear all those and get only base activity which are ActivityA and ActivityB. – bala Apr 02 '14 at 08:33

0 Answers0