+-

我使用AlarmManager启动服务.当我设置AlarmManager时,我使用PendingIntent并使用一个唯一的requestCode,它等于数据库中的id行.
PendingIntent pendingIntent = PendingIntent.getBroadcast(SettingsActivity.this,
lecture.getId(), myIntent, 0);
启动时如何在服务中检索该ID?我基本上只需要requestCode参数.我想使用该ID从数据库中检索数据并在通知中显示.我已经实现了所有东西,我只需要那个requestCode.有可能得到吗?
谢谢
最佳答案
您需要将tutorial.getId()放入myIntent的其他内容中.根据Javadoc,甚至还没有使用 requestCode.
// store id
myIntent.putExtra("id", lecture.getId());
// read id or -1, if there is no such extra in intent
int id = myIntent.getIntExtra("id", -1);
点击查看更多相关文章
转载注明原文:android-PendingIntent获取requestCode - 乐贴网