hookshy Well-Known Member Licensed User Longtime User Mar 24, 2014 #1 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 ? Code: Copy 'statement from service create notif.Initialize notif.Icon="icon" 'statement from sub notif.sound=False notif.Vibrate=False Service.StartForeground(1,notif) ' start foregound
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 ? Code: Copy '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 Mar 24, 2014 #2 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
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
Erel B4X founder Staff member Licensed User Longtime User Mar 24, 2014 #3 Why is it so important that the activity will not be killed? You should treat the activity as a simple UI form. Upvote 0
Why is it so important that the activity will not be killed? You should treat the activity as a simple UI form.
hookshy Well-Known Member Licensed User Longtime User Mar 25, 2014 #4 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
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
Erel B4X founder Staff member Licensed User Longtime User Mar 25, 2014 #5 You can load the bitmap once and store them in process global variables. Services can run in the background. Activities are paused when they are in the background and they can be killed. You should expect your activities to be destroyed and later created. See this thread: Android Process and activities life cycle Upvote 0
You can load the bitmap once and store them in process global variables. Services can run in the background. Activities are paused when they are in the background and they can be killed. You should expect your activities to be destroyed and later created. See this thread: Android Process and activities life cycle
hookshy Well-Known Member Licensed User Longtime User Mar 25, 2014 #7 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
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 .