Android如何在按下通知时激活活动

Android如何在按下通知时激活活动,android,notifications,android-intent,Android,Notifications,Android Intent,单击通知栏上的图像后,我如何确定活动的意图? 我怎样才能作出决定? 谢谢 您发布的代码中已经有一个意图,例如,您在contentIntent中有一个新的intent()。它没有多大用处,因为您没有在其中填充任何内容。你需要这样的东西 Intent notificationIntent = new Intent(this, MyAvtivity.class); // modify the intent as nessasary here. PendingIntent contentIntent =

单击通知栏上的图像后,我如何确定活动的意图? 我怎样才能作出决定? 谢谢


您发布的代码中已经有一个意图,例如,您在contentIntent中有一个新的intent()。它没有多大用处,因为您没有在其中填充任何内容。你需要这样的东西

Intent notificationIntent = new Intent(this, MyAvtivity.class);
// modify the intent as nessasary here.
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

用户指南

感谢您的指导。我像这样放置PendingEvent contentIntent=PendingEvent.getActivity(上下文,0,新意图(上下文,KeepBridgeActivity.class),0);无论如何,谢谢!同样的问题也发生在我身上,你的解决方案也奏效了…-)干杯
Intent notificationIntent = new Intent(this, MyAvtivity.class);
// modify the intent as nessasary here.
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);