[英]How to choice activity to open when notification clicked
Is there way to choice the activity to start just in moment of clicking notification? 有没有选择活动的方法,该活动仅在单击通知时立即开始? I can use
setContentIntent
when I build notification. 构建通知时可以使用
setContentIntent
。 But being once shown it seems not possible to set or change content intent in moment of click... 但是一旦显示出来,似乎无法在点击时设置或更改内容意图...
我建议的解决方法是将setContentIntent定向到一个简单的活动,该活动根据您选择的意图在onCreate()中处理特定情况。
try this 尝试这个
Intent intent = new Intent(this, YOURACTIVITY.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setContentIntent(pendingIntent);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.