permissions.monkey2 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #If __TARGET__="android"
  2. Namespace myapp
  3. #Import "<std>"
  4. #Import "<mojo>"
  5. Using std..
  6. Using mojo..
  7. Class MyWindow Extends Window
  8. Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )
  9. Super.New( title,width,height,flags )
  10. Print "Hello World from permissions demo!"
  11. Local permissions:=New String[](
  12. "android.permission.INTERNET",
  13. "android.permission.ACCESS_NETWORK_STATE",
  14. "android.permission.READ_EXTERNAL_STORAGE",
  15. "android.permission.WRITE_EXTERNAL_STORAGE",
  16. "com.android.vending.BILLING" )
  17. For Local i:=0 Until permissions.Length
  18. Print "CheckPermission(~q"+permissions[i]+"~q)="+CheckPermission( permissions[i] )
  19. Next
  20. RequestPermissions( permissions,Lambda( results:int[] )
  21. If Not results
  22. Print "RequestPermissions cancelled"
  23. Return
  24. Endif
  25. For Local i:=0 Until results.Length
  26. If results[i]
  27. Print "Permission granted for "+permissions[i]
  28. Else
  29. Print "Permission NOT granted for "+permissions[i]
  30. Endif
  31. Next
  32. End )
  33. End
  34. Method OnRender( canvas:Canvas ) Override
  35. Global n:Int
  36. n+=1
  37. App.RequestRender()
  38. canvas.DrawText( "Hello World! n="+n,Width/2,Height/2,.5,.5 )
  39. End
  40. End
  41. Function Main()
  42. New AppInstance
  43. New MyWindow
  44. App.Run()
  45. End
  46. #Endif