Here is the problem. My program is running perfect in Android 6.0. After update the device to android 7.0. Pendingintent can not pass the parcelable data to boradcast reveiv
Following the suggesting of @David Wasser in the comments underneath the question, I was able to resolve the same problem like this:
public static void setAlarm(@NonNull Context context, @NonNull Todo todo) {
...
Intent intent = new Intent(context, AlarmReceiver.class);
Bundle todoBundle = new Bundle();
todoBundle.putParcelable("KEY_TODO", todo);
intent.putExtra("KEY_TODO", todoBundle); // i just reuse the same key for convenience
...
}
Then in the broadcast receiver extract the bundle like this:
public void onReceive(Context context, Intent intent) {
Bundle todoBundle = intent.getBundleExtra("KEY_TODO");
Todo todo;
if (todoBundle != null ) {
todo = todoBundle.getParcelable("KEY_TODO");
}
}