How does Android handle backlight timeouts?
I am developing a simple app. I want to make sure that the simple calculation the app performs is stopped when the backlight times out. Does the OS handle this automatically? Does it "paus开发者_JS百科e()" or "stop()" the foreground activity? Or do i need to set up a BroadcastReceiver to listen for an android.intent.action.SCREEN_OFF, and one for SCREEN_ON?
When the screen goes off, or the user navigates away from your activity, then onPause() is called. When the activity is resumed, onResume() is called. Read more on the activity lifecycle here: http://developer.android.com/reference/android/app/Activity.html
精彩评论