Getting data from clicked notification in android

元气小坏坏 提交于 2019-12-01 10:48:18

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!