У меня есть этот код ниже, который работает и показывает локальное уведомление!
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>
При нажатии на локальное уведомление не открывается приложение. Это не уведомление pu sh, поэтому я могу добавить какое-то действие.
Как я могу открыть приложение при нажатии на местное уведомление?