I have a code module that contain the below code. Even though I have the "android.permission.READ_EXTERNAL_STORAGE" permission in the manifest, I am still getting this error on an Android 8.x device.
B4X:
Sub DoNotification(VibCount As Int, SoundURI As String, Vol As Int)
Dim V As Float
Dim Pv As PhoneVibrate
Try
If Starter.MP.IsPlaying Then
Starter.MP.Stop
End If
Catch
Log(LastException)
End Try
'play audio first
If SoundURI.Trim <> "" Then
Starter.MP.Load("ContentDir", SoundURI)
V = Vol / 100
Starter.MP.SetVolume(V,V)
Starter.MP.Play
End If
If VibCount > 0 Then
Do While VibCount > 0
Log("VibCount=" & VibCount)
Pv.Vibrate(1000)
Sleep(2000)
VibCount = VibCount - 1
Loop
End If
End Sub
B4X:
common$ResumableSub_DoNotificationresume (java line: 207)
java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/audio/media/1395 from pid=1452, uid=10120 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:2013)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:146)
at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:698)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1410)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1247)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1170)
at anywheresoftware.b4a.objects.MediaPlayerWrapper.loadAfterReset(MediaPlayerWrapper.java:91)
at anywheresoftware.b4a.objects.MediaPlayerWrapper.Load(MediaPlayerWrapper.java:66)
at com.comp.appcommon.common$ResumableSub_DoNotification.resume(common.java:207)
at com.comp.appcommon.common._donotification(common.java:99)
at com.comp.appcommon.commontimer._tmrmain_tick(commontimer.java:586)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)