What I want to do is pass data through intent,
code >> the creator
intent = new Intent(this, AlarmReceiverActivity.class);
intent.putExtra("id", id);
intent.putExtra("R/N", a);
pendingIntent = PendingIntent.getActivity(this, id, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
code >> the receiver
MainExtras = getIntent();
if (MainExtras != null) {
MainValue = MainExtras.getIntExtra("id", 000);
Log.d("MainValue", "" + (MainValue +1));
MainRon = MainExtras.getStringExtra("R/N");
Log.d("MainRon", "" + MainRon);
}else{
Log.d("Failed to get Extras ...", "FAIL -.-");
}
This works just fine if I dont turn of the activity that created the intent, but if I do "THE receiver doesnt get the extras". Do you have any ideas?
I have not tried this but i am assuming if you change the flag to a Flag indicating that if the described PendingIntent already exists, then keep it but replace its extra data with what is in this new Intent.
Intent in = new Intent(context, RecievingActivity.class );
in.putExtra( "notification_id", REGISTER_NOTIF_ID);
in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
in.putExtra("2", Variable);
in.putExtra("1", Variable);
in.putExtra("IMData", Variable);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, in, 0);
and add the following to your RecievingActivity.class
Bundle extras = getIntent().getExtras();
userGetId = extras.getString("2");
userNameRecv = extras.getString("1");
userFriendId = extras.getString("IMData")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.