skip to Main Content

Trying to implement the notification permission for android 13 or "Tiramisu" but failed to get the import for that permission.

Currently:
targeted SDK version is 32
compile SDK version is 32

I’ve declared it also in manifiest as below:

 <uses-permission android:name="android.permission.POST_NOTIFICATIONS"

import i’m using:

import android.Manifest
  • But even not getting import in my fragment.

enter image description here

6

Answers


  1. Chosen as BEST ANSWER
         android {
         namespace 'com.example.myapplication'
        compileSdkVersion 33//update this
    
         defaultConfig {
            applicationId "com.example.myapplication"
            minSdk 23
            targetSdkVersion 33//update this
            versionCode 1
            versionName "1.0"
            
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    

  2. I faced the same problem,

    Steps to fix :

    Install SDK Platforms
    SDK Platform 33
    Android TiramisuPrivacy Sandbox Preview

    enter image description here

    Install SDK Tools :
    Android SDK build Tools 33
    enter image description here

    Login or Signup to reply.
  3. I solved it by using compileSdkVersion 33 in the gradle file at the Module level. Then it allowed me to use the POST_NOTIFICATIONS permission without any issue.
    Gradle Settings

    Login or Signup to reply.
  4. Just add this import:

    import android.Manifest
    
    Login or Signup to reply.
  5. Set targetSDKVersion to 33.

    If for some reason it complains about your minimum supported and you’re in no position to update, use the following instead:

    NotificationManagerCompat.from(this).areNotificationsEnabled()
    
    Login or Signup to reply.
  6. You need to prefix the Manifest statement with android., e.g.,

                if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.POST_NOTIFICATIONS) ==
                    PackageManager.PERMISSION_GRANTED)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search