I have a problem, my MainActivity can be created in three ways: 1) a standard application to run 2) from a service 3) from notifications click. How can I check when it starts with a notification, click?
Notification Code:
private void createNotification() { Log.d("service createNotification",MainActivity.TAG); Context context = getApplicationContext(); Intent notificationIntent = new Intent(this,MainActivity.class); intent.putExtra(AppNames.IS_NOTIFICATION_INTENT,true); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle(this.getString(R.string.notification_title)) .setContentText(this.getString(R.string.notification_text)) .setContentIntent(pendingIntent) .setSmallIcon(R.drawable.ic_launcher); getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(AppNames.APP_NOTIFICATION, builder.getNotification()); }
android
Abbath
source share