我有一個活動讓用戶通過選擇日期和時間來安排事件。我已經使用AlarmManager在運行android 2.3.3的設備中獲取'java.lang.IllegalArgumentException:無法使用FLAG_RECEIVER_BOOT_UPGRADE'
Intent i=new Intent(context, AlarmReceiver.class);
i.putExtra("status",status);
i.putExtra("mode",mode);
PendingIntent p=PendingIntent.getBroadcast(context, id, i, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarms.set(AlarmManager.RTC_WAKEUP, sched_time, p);
在廣播接收器中的新的活動被啓動
@Override
public void onReceive(Context context, Intent data) {
// Start the scheduled post
String status=data.getExtras().getString("status");
int mode=data.getExtras().getInt("mode");
Intent i=new Intent(context,PostScheduled.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra("status", status);
i.putExtra("mode", mode);
context.startActivity(i);
}
在仿真器中此代碼運行正常但在實際裝置(運行Android 2.3.3)崩潰在線路
PendingIntent p=PendingIntent.getBroadcast(context, id, i, PendingIntent.FLAG_CANCEL_CURRENT);
這裏的堆棧跟蹤
java.lang.IllegalArgumentException: Can't use FLAG_RECEIVER_BOOT_UPGRADE here
at android.os.Parcel.readException(Parcel.java:1326)
at android.os.Parcel.readException(Parcel.java:1276)
at android.app.ActivityManagerProxy.getIntentSender(ActivityManagerNative.java:2254)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:230)
at com.social.autofunnystatus.ScheduleDialog.onClick(ScheduleDialog.java:158)
at android.view.View.performClick(View.java:2538)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
任何人有任何線索是怎麼回事?
http://stackoverflow.com/questions/5438681/android-error-cant-use-flag-receiver-boot-upgrade-here – jellyfication 2012-04-19 13:12:45
@jellyfication線程不回答什麼:(我有一個額外的問題,該應用程序不會在仿真程序上崩潰(也運行2.3.3) – Mehedi 2012-04-19 13:31:54
當您調用'PendingIntent.getBroadcast(..)'時,通過'i'參數傳遞什麼信息?考慮添加此'Intent – Jens 2012-04-19 14:14:25