我试图获得未决意图。当我点击通知时它的返回意图很好。但是,当我通过启动器图标打开我的应用程序时它没有返回任何东西它没有返回待处理的意图。我搜索了许多链接,但没有得到任何东西。
从服务
创建待处理意图.icon { font-family: MyCoolIconFont; }
当用户通过启动器启动应用时,在活动中获得待处理意图
Intent in = new Intent(this, MainActivity.class);
in.setAction(action);
in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
in.putExtras(bundle);
PendingIntent pendIntent = PendingIntent.getActivity(this, 0, in,0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("Wiphone")
.setContentText(callStatus)
.setSmallIcon(R.drawable.ic_wifi)
.setWhen(System.currentTimeMillis())
.setAutoCancel(false)
.setOngoing(true)
.setPriority(Notification.FLAG_FOREGROUND_SERVICE)
.setContentIntent(pendIntent);
Notification notification = builder.build();
notification.flags |= Notification.FLAG_NO_CLEAR;
startForeground(10, notification);