Android Question Activities background

scsjc

Well-Known Member
Licensed User
Longtime User
it is possible to do something so that an activity is in the background, and not killed by the system, or try to last as long as possible on background.

thanks
 

Stoian

Member
Licensed User
It is simple example with timer (do something in every 1 min).

Starter:
B4X:
Sub Process_Globals
    Dim note As Notification
    Dim ph As PhoneWakeState
    
    Dim tmr As Timer
 
End Sub
Sub Service_Start (StartingIntent As Intent)
    note.Initialize
    note.Icon="icon"
    note.SetInfo("title","body",Main)
    note.Notify(1)
    
    Service.StartForeground(1,note)
    ph.PartialLock
    
    ' - Your code...
    tmr.Initialize("tmr",60000)
    tmr.Enabled=True
    
    
End Sub


Sub tmr_Tick
       'do something
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…