说明:
我用过Daemon Thread。
在我的应用程序中,当用户发送任何文件(.jpg,.txt,.pdf等)时,它将为每个文件生成单独的通知。
假设有3个通知。
当用户点击任何通知时,它会根据文件调用android.content.Intent.ACTION_VIEW
并建议使用openwith选项。
问题: 当用户选择通知时,它将在相应的应用程序中打开(例如,如果用户选择sample.txt,那么它将在colornote中打开)并且 之后当用户点击另一个通知时,它将什么都不做,然后就会发生同样的事情。
我已通过通知的唯一ID ...!
long timestamp=System.currentTimeMillis();
int i=(int) timestamp;
mNotificationManager.notify(i, mBuilder.build());
请帮我找错。
答案 0 :(得分:2)
您需要将PendingIntent
添加到通知构建器:
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(MyActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);