About Monkey 2 › Forums › Monkey 2 Programming Help › Help with Android Permissions
Tagged: Android, permissions
This topic contains 4 replies, has 3 voices, and was last updated by
Mark Sibly
4 months ago.
-
AuthorPosts
-
December 11, 2018 at 4:22 pm #15683
Hello everyone at Monkey2 community!
I’m having problem asking at run-time Android permissions.
I’m testing this with the following code:
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )Print "Hello World from permissions demo!"Local permissions:=New String[]("android.permission.INTERNET","android.permission.ACCESS_NETWORK_STATE","android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE","com.android.vending.BILLING" )For Local i:=0 Until permissions.LengthPrint "CheckPermission(~q"+permissions[i]+"~q)="+CheckPermission( permissions[i] )NextRequestPermissions( permissions,Lambda(results:ResultType[] )Print "Hello Wolrd from Request Permissions..."If Not resultsPrint "RequestPermissions cancelled"ElseFor Local i:=0 Until results.LengthIf results[i]Print "Permission granted for "+permissions[i]ElsePrint "Permission NOT granted for "+permissions[i]EndifNextEndifEnd )EndMethod OnRender( canvas:Canvas ) OverrideGlobal n:Intn+=1App.RequestRender()Local permissions:=New String[]("android.permission.INTERNET","android.permission.ACCESS_NETWORK_STATE","android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE","com.android.vending.BILLING" )For Local i:=0 Until permissions.Lengthcanvas.DrawText("CheckPermission(~q"+permissions[i]+"~q)="+CheckPermission( permissions[i] ),10,i*20)Nextcanvas.DrawText( "Hello World! n="+n,Width/2,Height/2,.5,.5 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndWhen running the program from ADB, I get following lines:
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606112/11 18:10:10: Launching app$ adb shell am start -n "com.monkey2.monkey2game/com.monkey2.monkey2game.Monkey2Game" -a android.intent.action.MAIN -c android.intent.category.LAUNCHERClient not ready yet..Waiting for process to come onlineConnected to process 5151 on device samsung-sm_a605fn-4980c8cbCapturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.I/zygote: no shared libraies, dex_files: 1I/InstantRun: starting instant run server: is main processV/SDL: Device: a6plteModel: SM-A605FNV/SDL: onCreate(): nullV/SDL: onResume()D/OpenGLRenderer: HWUI GL PipelineD/ViewRootImpl@e980985[Monkey2Game]: setView = DecorView@b80c3da[Monkey2Game] TM=true MM=falseV/InputMethodManager: Not IME target window, ignoringD/ViewRootImpl@e980985[Monkey2Game]: dispatchAttachedToWindowV/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0D/ViewRootImpl@e980985[Monkey2Game]: Relayout returned: old=[0,0][0,0] new=[0,0][2094,1080] result=0x7 surface={valid=true 3508287488} changed=trueI/Adreno: QUALCOMM build : 27fc0ac, I6722ec3024Build Date : 04/09/18OpenGL ES Shader Compiler Version: EV031.22.00.01Local Branch :Remote Branch : refs/tags/AU_LINUX_ANDROID_LA.UM.6.5.R1.08.00.00.312.043Remote Branch : NONEReconstruct Branch : NOTHINGI/Adreno: PFP: 0x005ff087, ME: 0x005ff063I/OpenGLRenderer: Initialized EGL, version 1.4D/OpenGLRenderer: Swap behavior 2D/libGLESv1: STS_GLApi : DTS, ODTC are not allowed for Package : com.monkey2.monkey2gameD/OpenGLRenderer: eglCreateWindowSurface = 0xe1c57b20D/SurfaceView: BG show() Surface(name=Background for - SurfaceView - com.monkey2.monkey2game/com.monkey2.monkey2game.Monkey2Game@a54b901@0) org.libsdl.app.SDLSurface{a54b901 VFE...... .F....ID 0,0-2094,1080}V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0D/SurfaceView: surfaceCreated 1 #8 org.libsdl.app.SDLSurface{a54b901 VFE...... .F....ID 0,0-2094,1080}V/SDL: surfaceCreated()D/SurfaceView: surfaceChanged (2094,1080) 1 #8 org.libsdl.app.SDLSurface{a54b901 VFE...... .F....ID 0,0-2094,1080}V/SDL: surfaceChanged()pixel format RGB_565V/SDL: Window size: 2094x1080D/SensorManager: registerListener :: 0, LSM6DSL Accelerometer, 20000, 0,I/SDL: SDL_Android_Init()SDL_Android_Init() finished!D/ViewRootImpl@e980985[Monkey2Game]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 2094, 1080) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 63 - 0, 0) or=2MSG_WINDOW_FOCUS_CHANGED 1V/SDL: onWindowFocusChanged(): trueV/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@e3743a6 nm : com.monkey2.monkey2game ic=nullI/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocusD/AudioTrack: Client defaulted notificationFrames to 1181 for frameCount 3544W/AudioTrack: Use of stream types is deprecated for operations other than volume controlW/AudioTrack: See the documentation of AudioTrack() for what to use instead with android.media.AudioAttributes to qualify your playback use caseD/ViewRootImpl@e980985[Monkey2Game]: Relayout returned: old=[0,0][2094,1080] new=[0,0][2094,1080] result=0x3 surface={valid=true 3508287488} changed=falseI/AudioTrack: updateAudioTranstionLength FadeIn[0] FadeOut[0] FadeInRing[0]I/OpenAL: _SC_NPROCESSORS_ONLN=8V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@c83f432 nm : com.monkey2.monkey2game ic=nullD/ViewRootImpl@e980985[Monkey2Game]: Relayout returned: old=[0,0][2094,1080] new=[0,0][2094,1080] result=0x1 surface={valid=true 3508287488} changed=falseD/ViewRootImpl@e980985[Monkey2Game]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 2094, 1080) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=2I/MX2: Hello World from permissions demo!I/MX2: CheckPermission("android.permission.INTERNET")=1I/MX2: CheckPermission("android.permission.ACCESS_NETWORK_STATE")=1I/MX2: CheckPermission("android.permission.READ_EXTERNAL_STORAGE")=0I/MX2: CheckPermission("android.permission.WRITE_EXTERNAL_STORAGE")=0CheckPermission("com.android.vending.BILLING")=1D/libGLESv2: STS_GLApi : DTS, ODTC are not allowed for Package : com.monkey2.monkey2gameSome remarks:
- I don’t see “Hello Wolrd from Request Permissions…”
- DTS, ODTC are not allowed for Package : com.monkey2.monkey2game
The problem is: The Android device doesn’t ask permissions to READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE.
Please, someone experienced with these things, say something about the problem.
December 13, 2018 at 12:00 pm #15686I made some changes to \modules\std\permissions.monkey2 and now asking permission at run-time works like a charm…
December 13, 2018 at 1:32 pm #15687I’d suggest opening an ‘issue’ on Github with the solution — it would help others and save you having to manually change it each time if accepted.
December 13, 2018 at 7:01 pm #15688I opened an issue on Github on the permissions. I attached the permissions.monkey2 as such I altered it.
December 15, 2018 at 12:33 am #15690Thank you, I will integrate this with the next binary release.
-
AuthorPosts
You must be logged in to reply to this topic.