android - Why Activity onPause calling only if i press Back or Home button? -


i'm need save playing time prefferensses when app close if click on task manager , close app or switch other , close time ago app doesent save anything.

code of onstop

@override protected void onstop() {     super.onstop();     log.d("", "mainactivity: onstop()");     searchfragment.spref = mainactivity.this.getpreferences(context.mode_private);     sharedpreferences.editor ed = searchfragment.spref.edit();     ed.putlong("saved_time", searchfragment.mediaplayer.getcurrentposition());     ed.commit(); } 

if 'onpause' has been called , activity still in 'background', wouldn't called anymore. life cycle of activity: http://developer.android.com/images/activity_lifecycle.png

maybe need print logs in 'onpause' , check when called.


Comments