【发布时间】:2014-04-28 21:55:36
【问题描述】:
我遇到了由 BroadcastReceiver 启动的活动的问题。
我使用此活动覆盖默认锁屏,我希望该活动不从堆栈映射。
我尝试使用各种标志:FLAG_ACTIVITY_NO_HISTORY、FLAG_ACTIVITY_CLEAR_TOP、FLAG_ACTIVITY_CLEAR_TASK...但所有这些都不起作用。
Receiver.java
public class Receiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
context.startService(new Intent(context, MyService.class));
Intent intent = new Intent(context, AppActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
//intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent);
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.lockscreen" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="com.app.AppActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTop" android:noHistory="true">
<intent-filter >
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
</intent-filter>
</activity>
<service android:name="com.app.MyService" android:noHistory="true">
</service>
<receiver android:name="receiver.Receiver" android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
【问题讨论】:
标签: android android-activity broadcastreceiver history