How can I open an active but minimized application from NotificationCompat.Builder (context) which content should be passed to it or something else.
1 answer
Something like this
Intent intent = new Intent(this, StartActivity.class); PendingIntent pIntent = PendingIntent.getActivity(this, id, intent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Builder nb = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_notification) .setAutoCancel(false) .setTicker(getString(R.string.app_full_name)) .setContentText(getString(R.string.app_full_name)) .setContentIntent(pIntent) .setContentTitle(getResources().getString(R.string.app_name)) .setDefaults(Notification.DEFAULT_ALL); Notification statusNotification = nb.build(); manager.notify(id, statusNotification);
upd: Then you need to add a flag, try this:
intent.setFlags(FLAG_ACTIVITY_CLEAR_TOP);
or so:
intent.setFlags(FLAG_ACTIVITY_SINGLE_TOP);
- It opens a new activation, but I need to open a minimized application, for example, I opened the application and minimized it, then maybe after a short time I brought out the notification by pressing which this minimized application should open and not rediscover it. - J Mas
- one@JTan, Updated the answer. - katso
|