1

How can I (if its possible) to force open notification? Like in incoming call on reminder notification?

 Intent intent = new Intent(context, ResultActivity.class);
            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

            NotificationCompat.Builder b = new NotificationCompat.Builder(context);

            b.setAutoCancel(true)
                    .setDefaults(Notification.DEFAULT_ALL)
                    .setWhen(System.currentTimeMillis())
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setTicker("Hearty365")
                    .setContentTitle("Default notification")
                    .setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
                    //.setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_SOUND)
                    .setContentIntent(contentIntent)
                    .setContentInfo("Info")
            .addAction(android.R.drawable.ic_media_pause, "Start", contentIntent)
                    .addAction(android.R.drawable.ic_dialog_alert, "Pause", contentIntent);



            NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.notify(1, b.build());

enter image description here

CherryDT
  • 25,571
  • 5
  • 49
  • 74
Dim
  • 4,527
  • 15
  • 80
  • 139

2 Answers2

1

As far as i know you cannot open (click on) a notification programmatically.

The closest thing you can do is expand the notifications panel.

For expanding the notifications panel see this answer.

Community
  • 1
  • 1
earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63
0

Hi @Dim only you have to add one line in your Notification Builder.

.setOngoing(true)

Hopefully it will work. :)

Kaushal Kishor
  • 411
  • 4
  • 9