我有下面的代码正在运行,并显示本地通知!
MainActivity.java
//
Intent intent = new Intent(GlobalApplication.getAppContext(), AlarmReceiver.class);
intent.setAction("android.intent.action.MAIN");
intent.putExtra("NotificationText", "some text");
PendingIntent pendingIntent = PendingIntent.getBroadcast(GlobalApplication.getAppContext(), 4, intent, PendingIntent.FLAG_UPDATE_CURRENT);
sendBroadcast(intent);
//
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "CHANNEL_ID")
.setSmallIcon(R.drawable.ic_launcher_background)
.setContentTitle("Please keep app running")
.setContentText("This is KILLER notification brother")
.setPriority(NotificationCompat.PRIORITY_HIGH);
Log.e(TAG, "Notified AOS to post notification");
notificationManager.notify(123, builder.build());
AndroidManifest.xml
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
点击本地通知不会打开应用程序。 这不是推送通知,因此我可以添加一些操作。
点击本地通知后,我如何才能打开应用?