Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setFullScreenIntent does not work second time

I have an application in android and I want to bring an activity to foreground in some cases. I use NotificationManager for this. Here is my code. The problem is, activity is brought to front successfully at first time, but then it does not. Also, this code is run from service.

Intent notificationIntent = new Intent(context, MainActivity.class);
            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

            NotificationCompat.Builder mBuilder =
                        new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setContentIntent(contentIntent)
                        .setContentTitle("Bring me front!")
                        .setContentText("Bring me!!! BRING!!!")
                        .setFullScreenIntent(contentIntent, true);

            NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.notify(0, mBuilder.build());
like image 402
Anhayt Ananun Avatar asked Jun 16 '26 08:06

Anhayt Ananun


2 Answers

The NotificationManager has the (undocumented) behavior that it will ignore the fullScreenIntent field if you post a new Notification that matches the ID of one that's already active.

like image 113
Yavor Mitev Avatar answered Jun 17 '26 22:06

Yavor Mitev


I had a similar problem. In my case I missed two things:

  1. USE_FULL_SCREEN_INTENT permission in Manifest.
  2. A password or graphic pattern must be set on your phone settings. UI must be NOT available to the user immediately after you press the unlock button. Then fullscreen activity shows.
like image 39
antaki93 Avatar answered Jun 17 '26 22:06

antaki93