如何使用应用程序的通知启动新应用程序。 NotificationManager没有为我提供允许我访问生成的通知的方法。有什么建议?感谢。
答案 0 :(得分:0)
您必须使用PendingIntent
创建通知。来自Android Developers:
Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(this, MyClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
private static final int HELLO_ID = 1;
mNotificationManager.notify(HELLO_ID, notification);
MyClass
是您希望从通知开始的活动。