Android Question [SOLVED] B4X Intent based camera

fbritop

Active Member
Licensed User
Longtime User
I discovered today that when I use the Intent Camera on B4A the previous page "B4XPage_Appear" does not execute, not sure if it has something to do with the Bug that was discovered on iOS?

From page A, I navigate to a Page B, which takes the picture, this page shows the image to the user. Then when the user goes back using B4XPages.ShowPageAndRemovePreviousPages("A") it does not call B4XPage_Appear on page A, It does not hapen if the user does not take the picture (or activates the intent). I have a Class that handles the Intent Camera (because it its used in many modules).

Someone has faced something similar?

PD: When the camera intent is used (open camera), then none of the "B4XPage_Appear" subs in any B4Xpage works again. If I minimize the app and then restore it, it triggers the B4XPage_Appear event again on every B4XPage

Original thread from https://www.b4x.com/android/forum/threads/b4x-b4xpages-intent-based-camera.120721/#content
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tried the example project as is, with only the addition of B4XPages logs:
B4X:
B4XPages.GetManager.LogEvents = True

This is the output:

** Activity (main) Pause event (activity is not paused). **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Using FileProvider? true
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
*** mainpage: B4XPage_Disappear [mainpage]
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
** Activity (main) Resume **
*** mainpage: B4XPage_Appear [mainpage]
** Activity (main) Pause event (activity is not paused). **
*** mainpage: B4XPage_Disappear [mainpage]
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
Orientation: 6
** Activity (main) Resume **
*** mainpage: B4XPage_Appear [mainpage]

It looks correct.
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Thanks @Erel but I think the problem goes beyond this scope, and it is related to the nasty Intents.

This logs gave me some clue
B4X:
INTENT
Bundle[{profile=UserHandle{0}}]
--- Intent
Action: android.intent.action.MAIN
ExtrasToString: Bundle[{profile=UserHandle{0}}]

I have just tested the App removing my intents on Main Resume module, and now it works correctly. I'm not sure if there is a way to "flush" the intent after the Activity_Resume?
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Thanks @Erel but I think the problem goes beyond this scope, and it is related to the nasty Intents.

This logs gave me some clue
B4X:
INTENT
Bundle[{profile=UserHandle{0}}]
--- Intent
Action: android.intent.action.MAIN
ExtrasToString: Bundle[{profile=UserHandle{0}}]

I have just tested the App removing my intents on Main Resume module, and now it works correctly. I'm not sure if there is a way to "flush" the intent after the Activity_Resume?
I've tried the example project as is, with only the addition of B4XPages logs:
B4X:
B4XPages.GetManager.LogEvents = True

This is the output:

** Activity (main) Pause event (activity is not paused). **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Using FileProvider? true
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
*** mainpage: B4XPage_Disappear [mainpage]
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
** Activity (main) Resume **
*** mainpage: B4XPage_Appear [mainpage]
** Activity (main) Pause event (activity is not paused). **
*** mainpage: B4XPage_Disappear [mainpage]
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
Orientation: 6
** Activity (main) Resume **
*** mainpage: B4XPage_Appear [mainpage]

It looks correct.
Solved. There was a missed line regarding Activity_Resume in Main that was not supposed to be there.

B4X:
If Activity.GetStartingIntent = lastintent Then Return
 
Upvote 0
Top