I have an activity which lets user to schedule an event by choosing
the date and time.I have done it using the AlarmManager

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

In the broadcast receiver a new Activity is launched

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



I have an activity which lets user to schedule an event by choosing
the date and time.I have done it using the AlarmManager

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

In the broadcast receiver a new Activity is launched

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

In the emulator this code runs fine but in actual device(running
android 2.3.3) it crashes at the line

PendingIntent p=PendingIntent.getBroadcast(context, id, i,
PendingIntent.FLAG_CANCEL_CURRENT);

Here's the Stack trace
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)

Please help.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to