我有一个活动X,它接收启动器意图并调用Y.Y注册一个广播接收器并调用moveTaskToBack(true)
。接收器执行startActivity(Y)
(将其带回到前面)但是当它应该带Y时它会将X带到顶部。
活动Y在manifest.xml
<activity
android:name=".Y"
android:label="@string/title_activity_input_password"
android:launchMode="singleInstance">
</activity
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.i("[YActivity]", "MyReceiver");
if(intent.getAction().equals(Intent.ACTION_SCREEN_ON)){
Log.i("[YActivity]", "Screen ON");
Intent i = new Intent(context, Y.class);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
// i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(i);
}
else if(intent.getAction().equals(Intent.ACTION_SCREEN_OFF)){
Log.i("[YActivity]", "Screen OFF");
}
}