Android Question Application in background event

Emme Developer

Well-Known Member
Licensed User
Longtime User
create a sub in the starterservice and call this sub from each activity.
Yes but this means that i need to add a sub in each activity. If i have 200 activities, i need 200 sub in activity.pause. I think this is not the best practice to achieve what i want
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
If your App goes in the background it should raise Activity_pause
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Patience will copy and paste 200 times
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
If you declare a MediaPlayer in the Starter service:

B4X:
Sub Process_Globals
    Public mp As MediaPlayer
End Sub

in each activity:
B4X:
Sub Activity_Pause (UserClosed As Boolean)
    Starter.mp.Pause
End Sub

B4X:
Sub Activity_Resume
    Starter.mp.Play
End Sub
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
To write simple program which enumerates all .bas/.b4a files and inserts a line after Activity_Pause, requires 15 minutes maximum

It would be even easier if you could use Quick Search - Replace With this way:

Sub Activity_Pause (UserClosed As Boolean) [special char] line to add

where [special char] should be a char for "new line" (CRLF) and you could get:

Sub Activity_Pause (UserClosed As Boolean)
line to add


Also I think that soon we will have the possibility to create activity templates, as it is currently possible with classes.
 
Last edited:
Upvote 0

Emme Developer

Well-Known Member
Licensed User
Longtime User
Guys thanks for all answers, but the problem is not to waste time to write a sub for each activity. Main problem is that i think is unbelievable that there is not a way to create a single event (so a single exit/entry point) to see the status of the app
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…