Android Question Activity_Resume run 2 times

D

Deleted member 103

Guest
Hi,

can someone tell me why the Activity_Resume is run 2 times?
What can I do to make the Activity_Resume run only once?
Or is it normal? If so, then I have not noticed until now.

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.

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("Layout1")
End Sub

Sub Activity_Resume
    Msgbox2Async("Message", "Titel", "OK", "", "", Null, False)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
@Filippo : I have perhaps found something : if the app is uploaded from B4A while the screen is OFF than the app is Resumed twice (it seems normal as I understand the app to be in the background). But if the screen is ON it does not resume twice.
But if the app is killed and relaunched it is again resumed twice.
Please could you confirm ?
 
Upvote 0

Star-Dust

Expert
Licensed User
Upvote 0

Star-Dust

Expert
Licensed User
I have done tests on other devices and it works correctly, unfortunately now I have to go

But I would suggest you to save DateTime.Now of each Resume.
If compared to the previous one restarts after less than a second then I would ignore it.

I hope you solve. See you next time ;)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Samsung Note 8, Android 8

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
 
Upvote 0
D

Deleted member 103

Guest
@Filippo : I have perhaps found something : if the app is uploaded from B4A while the screen is OFF than the app is Resumed twice (it seems normal as I understand the app to be in the background). But if the screen is ON it does not resume twice.
But if the app is killed and relaunched it is again resumed twice.
Please could you confirm ?
Yes
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
if the app is uploaded from B4A while the screen is OFF than the app is Resumed twice (it seems normal as I understand the app to be in the background). But if the screen is ON it does not resume twice.
This is expected and it normally only happens during development. It is not related to the issue Filippo encountered.
 
Upvote 0

CaptKronos

Active Member
Licensed User
Samsung S8, Android 8

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
 
Upvote 0
D

Deleted member 103

Guest
Samsung S8, Android 8

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
OK, now I am finished with my Latin. :(

it may be that the problem occurs only in the so-called cheap devices?
Then my theory is no longer correct. :(
 
Upvote 0
D

Deleted member 103

Guest
B4X:
Sub Activity_Resume
    Sleep(1000)
    Msgbox2Async("Message", "Titel", "OK", "", "", Null, False)
    Log("Time:" & DateTime.Time(DateTime.Now))
End Sub
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Time:09:06:43
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Time:09:06:48
 
Upvote 0
D

Deleted member 103

Guest
I have come a bit further now.
This log is when the app is run directly from B4a.
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Time:09:19:49
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Time:09:19:54

and this log when the app is killed and restarted.
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Time:09:18:28
 
Upvote 0
D

Deleted member 103

Guest
So, looks like the problem lies in B4a and Android 8.0.
Whenever an app is compiled and executed directly, the Sub Activity_resume is executed twice.
After that, if the app runs normally on the device, the sub Activity_resume will run only once.
 
Upvote 0
D

Deleted member 103

Guest
So, looks like the problem lies in B4a and Android 8.0.
Whenever an app is compiled and executed directly, the Sub Activity_resume is executed twice.
Now the error in B4a, if there is a mistake, perhaps resolved, but not necessarily.
 
Upvote 0
Top