Hey guys I need help on how to get the data from my pending intent which is set using a broadcast receiver. What I want to happen is to get the data of an id when the notifi
In your AlertReceiver
, you have declared
private int id;
and you use this int
value in
reminderActivity.putExtra("id", id);
So you also have to get it as an int
in your setContentFromDB()
method:
int reminderID = extras.getIntExtra("id", someInt);
titleTextView.setText("" + reminderID);
where 'someInt' should be an int
value which is normally never used or a default value if that makes sense in your case.
You got null from getStringExtra("id")
because that's the return value if no String
with key "id" was found.
And if you use an int
value with TextView.setText()
, it will be interpreted as a string resource. I think in your case ('id' is meant for database) that's bad.