I have an Android App with Push Notifications. I'm having a problem with some devices that when I send a push notification, the user's app opens automatically. I don't want to do that. I want the notification to show normally and if the users clicks on it, the app opens.
How do I prevent the app from opening automatically?
Here is the code from my intent for push notifications:
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, requestID, notificationIntent,
// Display a notification with an icon, message as content, and default sound. It also
// opens the app when the notification is clicked.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
NotificationManager notificationManager = (NotificationManager) getSystemService(
If you take a look at the documentation for the
NotificationCompat.Builder you can see the
setFullScreenIntent is the issue.
Documentation on that call:
An intent to launch instead of posting the notification to the status bar. Only for use with extremely high-priority notifications demanding the user's immediate attention, such as an incoming phone call or alarm clock that the user has explicitly set to a particular time. If this facility is used for something else, please give the user an option to turn it off and use a normal notification, as this can be extremely disruptive.
On some platforms, the system UI may choose to display a heads-up notification, instead of launching this intent, while the user is using the device.
You should remove
setFullScreenIntent from your builder.