I am making an application.
Now what i want is 开发者_StackOverflowthat whenever user Press HOME key on android, it does not go in Background Mode.Can any body give any suggestions how to implement all that?
Please Reply. Thanks a bunch in advance
You cannot (easily) force your app's process to exit, nor should you. You can force an activity to disappear from the stack when the user navigates away from it by adding android:noHistory="true"
to the manifest for that activity. But that will apply even to another activity in your app. You can also add android:finishOnTaskLaunch="true"
to force an activity to be closed down if the user launches it again from the home screen. However, the activity will run until then (or until the system shuts down the process for other reasons).
Android naturally keeps your application alive, but calls the onPause because it's not an active activity, then calls onResume when the user goes back to your application.
If you need to run code without a UI or you want it to be checking something then opening your app at some point You can use a service.
API Demos have some great examples of how to use a service
精彩评论