I am updating a V4 app to 26. I've been able to fix most of the issues. But not this one. One of the features of my app is the ability to silence the phone for a given period of time.
Error:
Failing line:
Manifest:
AAAND - I am running these lines (and Allowing):
I could find a Check and Request for ACCESS_NOTIFICATION_POLICY
Thanks for your help
Error:
B4X:
java.lang.SecurityException: Not allowed to change Do Not Disturb state
at android.os.Parcel.readException(Parcel.java:1693)
at android.os.Parcel.readException(Parcel.java:1646)
at android.media.IAudioService$Stub$Proxy.setRingerModeExternal(IAudioService.java:1264)
at android.media.AudioManager.setRingerMode(AudioManager.java:1311)
at anywheresoftware.b4a.phone.Phone.SetRingerMode(Phone.java:405)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA$1.run(BA.java:325)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Failing line:
B4X:
Ph.SetRingerMode(Ph.RINGER_SILENT)
Manifest:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetActivityAttribute(StopNagging2, android:theme, @android:style/Theme.Translucent.NoTitleBar)
'SetActivityAttribute(StopNagging2, android:theme, @android:style/Theme)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddPermission(android.permission.RECEIVE_SMS)
AddPermission(android.permission.PROCESS_OUTGOING_CALLS)
AddPermission(android.permission.READ_EXTERNAL_STORAGE) '6/4/18 - required for 26
AddPermission(android.permission.ACCESS_NOTIFICATION_POLICY) '6/4/18 - required for 26
AddReceiverText(DoSMSNotification, <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)
AddPermission(android.permission.READ_PHONE_STATE)
AddReceiverText(DoNotification, <intent-filter> <action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>)
AddReceiverText(DoNotification, <intent-filter> <action android:name="android.intent.action.SERVICE_STATE" />
</intent-filter>)
AddReceiverText(DoNotification, <intent-filter> <action android:name="android.provider.Telephony.LISTEN_MESSAGE_WAITING_INDICATOR" />
</intent-filter>)
AddReceiverText(UserPresent, <intent-filter> <action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>)
AddReceiverText(UserPresent, <intent-filter> <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>)
'End of default text.
AAAND - I am running these lines (and Allowing):
B4X:
RP.CheckAndRequest(RP.PERMISSION_READ_PHONE_STATE)
RP.CheckAndRequest(RP.PERMISSION_READ_EXTERNAL_STORAGE)
RP.CheckAndRequest(RP.PERMISSION_PROCESS_OUTGOING_CALLS)
RP.CheckAndRequest(RP.PERMISSION_RECEIVE_SMS)
Thanks for your help
Last edited: