Android Question AreNotificationsEnabled problem

Hi everyone
This Code for Check Notifications Are Enables or Not ,That's What I use:

AreNotificationsEnabled:
Private Sub AreNotificationsEnabled As Boolean 'areNotificationsEnabled method Added in API level 24
        Try
        Dim p As Phone : Log("SDK version : "&p.SdkVersion)
        Dim nJO As JavaObject
        Dim ctxt As JavaObject
        ctxt.InitializeContext
        nJO = nJO.InitializeStatic("android.support.v4.app.NotificationManagerCompat").RunMethod("from", Array(ctxt))
        Return nJO.RunMethod("areNotificationsEnabled", Null)
        Catch
            Log(LastException)
        Return False
        End Try
End Sub

in Android 13 or 14 its OK ,But in Android 7.1 and 9, I got This error :
(Exception) java.lang.Exception: java.lang.RuntimeException: Method: from not found in: androidx.core.app.NotificationManagerCompat

I am confused about this ,it is impossible!
 

Attachments

  • Untitled.png
    Untitled.png
    82.7 KB · Views: 40
Top