Android Question Process in foregound state

hookshy

Well-Known Member
Licensed User
Longtime User
I am putting a service module to foregound state with code below in order to keep activity from beeing killed .
It seems the OS android kill anyway the main activity , is this ok ? Is this happening due to low memory of device ?
I tried this solution to avoid activity recreation which lasts some time and user must access more fast the app functions.
Do I have to add something else ?
Is there any other way to make the activity availlable without any restictions ?



B4X:
'statement from service create
notif.Initialize
notif.Icon="icon"

'statement from sub
   notif.sound=False
        notif.Vibrate=False
        Service.StartForeground(1,notif) ' start foregound
 

hookshy

Well-Known Member
Licensed User
Longtime User
I am geting used with replying to my own questions : :)
I found in service tutorial that I can define sticky service.
#StartCommandReturnValue: android.app.Service.START_STICKY
in service attribute.
I understand that OS eventualy will kill the process then even if it will be recreated ..activity will still recreate also ...so there is no way in stoping the OS killing the main activity .
Please correct me if i am wrong !! and guide me please...
One of my users told me that the app is not running in backgound so ..I do not now how to handle this ! thanks
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
the app is used generaly to call or send sms by voice ...as I have other functionallity I do have bitmaps to load and a lot of other services, location..etc
loading contacts
I will try to load every thing when is first needed and reduce the time the main activity starts .

I am afraid I do not understand how to treat activity as simple UI Form , can you explain or share any resource doc.
Thanks
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
I realise I was a bad thing to put the process to forground unless for good reasons like playing music when user listen the music and knows
the process is out there running ...
I can not teach users about activity cycle . I will try to reduce the time the activity starts and on app exit ask the user if he wants to run process
in backgound ..in this way he will know that the process is running because he started this options himself ..
For more experenced users when checking the running processe it will find the started process running (as he will be always there because or the resquedule program)
Hope other to find this thread usefull .:)
 
Upvote 0
Top