Tuesday, 17 September 2013

Application is being killed while on background

Application is being killed while on background

My application always ends at some point while on background. I have read
that when the cpu usage of the application is low, the application is
being killed automatically. I already included a partial wake lock on my
onCreate method in my application using this code:
powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"MyWakeLock");
Then on pause:
protected void onPause()
{
super.onPause();
onBackground = true;
wakeLock.acquire();
Log.w("OnPause", "OnPause");
}
I really don't know how to prevent my application being killed. I also
tried using full wake lock but it is deprecated. Any ideas on how will I
keep my application alive on background? I never want my application to be
killed while on background. Thanks!

No comments:

Post a Comment