Android Question endless loop in check permission

Status
Not open for further replies.

dcoun

Member
Licensed User
Longtime User
In the main activity I have a sub that it is call by a resumable sub initiated by the activity_resume
It runs the command Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
in the Sub Activity_PermissionResult I have only a Log("perm: "&Result)
Any idea why I never see the permission window and I can see only the following in the logs


perm: false
** Activity (main) Resume **
main resume
true
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
main resume
true
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
main resume
true
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
main resume
true
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
** Activity (main) Pause, UserClosed = false **
 

dcoun

Member
Licensed User
Longtime User
Change it to not have any resumable subs.... The same results. Code follows:
B4X:
Sub Activity_Resume
Log("main resume")
GetReady
End Sub


Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    Log("perm: "&Result)
End Sub

Sub GetReady
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
End Sub
 
Upvote 0

dcoun

Member
Licensed User
Longtime User
With the following code I get:
B4X:
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
    Wait For PermissionResult (Permission As String, Result As Boolean)

** Service (starter) Start **
** Activity (main) Create, isFirst = true **
maincont
** Activity (main) Resume **
main resume
true
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
main$ResumeMessagerun (java line: 306)
java.lang.Exception: Sub activity_permissionresult was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA$2.run(BA.java:365)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:437)
at medsite.mypatients.main$ResumeMessage.run(main.java:306)
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:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
 
Upvote 0

dcoun

Member
Licensed User
Longtime User
The code now is:
B4X:
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
In the manifest I entered
AddPermission(android.permission.PERMISSION_READ_EXTERNAL_STORAGE)

and the problem continues
I can not find anything else in the tutorial

** Activity (main) Resume **
main resume
true
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
main resume
true
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
main resume
true
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
main resume
true
** Activity (main) Pause, UserClosed = true **
 
Upvote 0

dcoun

Member
Licensed User
Longtime User
I think this thread should be moved to bugs:
Create a new project, select library runtimepermissions
Change only the following code:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim rr As RuntimePermissions

End Sub

Sub Activity_Resume
        rr.CheckAndRequest(rr.PERMISSION_READ_EXTERNAL_STORAGE)
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        Log("perm: "&Result)

End Sub

If I run it, it shows:
running waiting messages (1)
perm: false
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
--------- beginning of system
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
perm: false
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **


To be honest I can not understand why this happen
 
Upvote 0
Status
Not open for further replies.
Top