I'm using notifications with fullscreen my code works find in Oreo
and below version
But when i'm running android-Q
I'm getting below exception
Use of fullScreenIntent requires the USE_FULL_SCREEN_INTENT permission
I'm using setFullScreenIntent()
for notifications with fullscreen
Here is my code
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "123");
notificationBuilder.setAutoCancel(true)
.setColor(ContextCompat.getColor(this, R.color.colorAccent))
.setContentTitle(getString(R.string.app_name))
.setContentText("Test")
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setFullScreenIntent(pendingIntent,true)
.setSmallIcon(R.drawable.ic_launcher_background)
.setAutoCancel(true);
mNotificationManager.notify(1000, notificationBuilder.build());
Apps that target Android 10 or higher and use notifications with fullscreen intents must request the USE_FULL_SCREEN_INTENT permission in their app's manifest file. This is a normal permission, so the system automatically grants it to the requesting app.
The QUERY_ALL_PACKAGES permission has been introduced with Android R (Android 11). This permission enables the application to be able to query the installed applications on an Android device. We recommend applying for this permission if your application is subject to the requirements by Google Play.
Here is the answer
Now wee need to add <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
permission in manifest file
Permissions changes for fullscreen intents
Apps that target Android Q or higher and use notifications with fullscreen intents must request the USE_FULL_SCREEN_INTENT
permission in their app's manifest file. This is a normal permission, so the system automatically grants it to the requesting app
SAMPLE CODE
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xxx.xxx.xxx">
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With