CPU still running when user leaves app - android

I am building an android app with a map inside of it. It seems that when the user leaves the app (home button or back button), the app still uses cpu. The User and Kernal field jump from 0.00% to about 0.86% (at max) all the time after the user leaves the app. It seems to be killing the battery in my phone if I don't force close the app. Could the GPS be the issue of always searching? How could I stop all running processes with GPS if that is the issue?
thanks!

To kill a process you can use
android.os.Process.killProcess(android.os.Process.<PID>());

Related

How to restart service on power button or at the same time if it is forced close by user using task manager?

I am facing a big issue in android service and I searched more than 3 days but I didn't get any solution so please help me.
Currently I am working on a lock screen based service project that make your phone more secure means no one unlock it easily that's work fine but the main problem is that if my application is forced close by user via task manager then it also force close the service of my app then after that, when user press lock button to unlock his phone then it directly open home screen.
Is there any way to restart my application service after few second or at the same time or at the time is user press power button.
In my app I am also disable default lock screen that,s why if my app is force close then after that no security is worked for phone it directly show home screen that's not good, if my app is forced close then at least it enable default lock screen.
Any one who have idea about this please help.
Thanks in advance.
In Android, it's usually not recommended to start the service on it's own even if it is explicitly killed by the user. I don't think if there is a way to start the service again if the user goes into settings and kills it. BTW did you specify the service as remote?

How can I trigger my app to reopen whenever the device sits idle for a period of time?

I have an app that needs to reopen when the device isn't used, I've searched the internet but I didn't find what I was looking for.
How can I automatically reopen my app when the device isn't used for 10 seconds?
maybe you want to use WAKE-LOCK, which prevents the screen from going blank after a period of non-use. Rather than "reopen" your app, simply prevent it from closing.
http://developer.android.com/reference/android/os/PowerManager.WakeLock.html
The wake lock is no longer in effect once your user has switched out activities.
And if I installed an app that woke itself back up to the forefront after I'd switched out and away from it I'd uninstall. What is it that you're trying to do that is so important you've got to pester your user even after they've left your app? Describe the scenario - maybe there's an alternative to annoying your user to death.

Keep app running when the screen is blank and locked

I want my app to keep running when the screen is blank and locked.
This is an instrumentation app that runs when the phone is in the pocket, so we can blank the screen to save power.
Currently:
If the phone locks automatically the screen goes blank and the app terminates. When the phone is unlocked the app needs to be re-started.
If the phone is manually locked (with a tap on the power button) the screen goes blank, the app stays running, but the data to voice output stops "working". When the phone is unlocked the app is still running and the data to voice starts "working" again.
I don't think WakeLock will do that for me. It's a function that's more like a sticky bit, as in load and don't terminate unless there is a specif command to terminate.
Any pointers to what I should be doing would be appreciated - thanks - Rob
Why don't you start a 'Service' that your Activity's can bind to. This can run even when your App isn't.
http://developer.android.com/reference/android/app/Service.html
A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use.
Imagine how a mp3 playing application works, same scenario.

Flex 4.5 - Android application keeps running in background, How can I shut it down?

I am building an Android application in Flex 4.5 and I am testing on a Samsung Galaxy S phone.
My application uses GPS and also Google maps.
When I run the application, and I try to close it, the application keeps on running in the background. I would like the application to stop when the user presses the device's home button or when the user clicks the back button until they leave the application.
How can I make the application shut down in both the cases?
This is how Android applications are supposed to work. See here: http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html
Your application's process is in either the "background" state (if the user pressed how) or "empty" state (if the user pressed back).
For starters, you can try using the Activity noHistory flag in the manifest. This will make sure an Activity is finished if navigated away from.
http://developer.android.com/guide/topics/manifest/activity-element.html#nohist

android - force close, stop the app altogether

Our app is working great until we shut down the phone. When we power it back on the app comes up but the buttons and anything else are not responding to anything. I a, thinking its because we are not killing the app altogether when the phone shuts down. How to properly do that? How to force the app to shut down properly when the phone is being shut down?
Your problem almost certainly lies elsewhere as the kernel will fully close any apps you have running when you shut the phone down.

Categories

Resources