Thanks a lot SoB!! Your solution is way cleaner than mine.


On Monday, October 22, 2012 8:14:01 PM UTC+5:30, Streets Of Boston wrote:
>
> No you shouldn't. The method onBackPressed is called for you by the OS.
>
> If you want to destroy (i.e. finish()) your activity when the device goes 
> asleep, register a broadcast receiver in your Java code that listens to the 
> Intent.ACTION_SCREEN_OFF broadcast. When this broadcast is received 
> 'finish' your activity.
>
> On Monday, October 22, 2012 9:51:29 AM UTC-4, Saksham Chand wrote:
>>
>> Hi,
>>
>> I am writing an application where if the device goes to suspend mode, the 
>> current activity should get destroyed, instead of being paused, and on 
>> wake-up, its parent activity should be displayed.
>>
>> Currently, what I've done is to call onBackPressed() from onStop() 
>> something like this:
>>
>> onStop()
>> {
>>     doCleanup();
>>     if (!bBackPressed)   // Bool to teel if back button was pressed or not
>>         super.onBackPressed();
>>     super.onStop();
>> }
>>
>> And in onSaveInstanceState() I'm doing nothing i.e. I'm not calling 
>> super.onSaveInstanceState().
>>
>> I want to ask if I can call onBackPressed from onStop???
>>
>> Thanks,
>> Saksham
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Discuss" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/android-discuss/-/XNpffzmW3z0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/android-discuss?hl=en.

Reply via email to