The above activity returns a value to the sender activity when finished but the return value doesn't match the updated value If Button_Click event is Asynchronous
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Value As String = "foo"
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout")
End Sub
Sub GetPermission(ActivityInstance As Object)
Wait For Activity_Pause (UserClosed As Boolean)
Log(Starter.rp.Check(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)) 'returns false even approved before
Log(Value) ' Returns "foo", expected "bar"
CallSubDelayed2(ActivityInstance, "ValidationComplete", Value)
End Sub
Sub Button1_Click
'if i comment out the resumable method CheckAndRequest everything works as expected
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
Value = "bar"
Activity.Finish
End Sub
Sub Activity_Resume
End Sub
Last edited: