0

有两个活动ActivityAActivityB两个都是做的singleTask。这里ActivityB属于类别HOME,并且设置为始终。我从on启动ActivityA,它按预期启动ActivityA,但是当按下HOME KEY(即ActivityB)时,ActivityA被破坏。 可能的原因是什么?如何阻止ActivityA被破坏?通过保持这两种活动。BroadcastReceiverACTION_BOOT_COMPLETED
singleTask

这是广播接收器:

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);
     }
   }
}

清单文件如下:

   <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>
4

0 回答 0