Android Question Switch Off Notifications by Intent, is it possible?

sn_nn

Member
Licensed User
Longtime User
Hi, EveryBody!

Some days ago in this forum i found the Erel's solution for changing Write_Settings_Permissions by intent:

B4X:
Public Sub screenBrightness(brightnessInt As Int)     '0..255
Dim rp As RuntimePermissions
   rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
   Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
   If Result Then
       If CanWriteToSystemSettings = False Then
           Dim in As Intent
           in.Initialize("android.settings.action.MANAGE_WRITE_SETTINGS", "package:" & Application.PackageName)
           StartActivity(in)
           Wait For Activity_Resume
           If CanWriteToSystemSettings = False Then
               Log("no permission...")
               Return
           End If
       End If
   End If
   Dim J As JavaObject
   J.InitializeContext
   J.RunMethod("setBrightness",Array(J,brightnessInt))
End Sub

#if JAVA
import android.content.Context;
public void setBrightness(Context mContext, int brightnessInt){
   android.provider.Settings.System.putInt(mContext.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE, android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
   android.provider.Settings.System.putInt(mContext.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, brightnessInt);
}
#End If

Sub CanWriteToSystemSettings As Boolean
   Dim p As Phone
   If p.SdkVersion >= 23 Then
       Dim ctxt As JavaObject
       ctxt.InitializeContext
       Dim settings As JavaObject
       settings.InitializeStatic("android.provider.Settings.System")
       Return settings.RunMethod("canWrite", Array(ctxt))
   End If
   Return True
End Sub

And for now i'm trying to understand - is it possible throw intent switch off Notifications of application?

Thanks for help!
 
Top