java - onBackPressed() not working while coming from another activity -



java - onBackPressed() not working while coming from another activity -

i have 3 activities: first, sec , third. used method in sec activity:

public void onbackpressed() { super.onbackpressed(); finish(); }

and on 3rd activity:

public void onbackpressed() { super.onbackpressed(); intent = new intent(third.this, second.class); startactivity(i); finish(); }

the problem when press button after coming 3rd activity, going first activity instead of finish(). exiting application when click button right after coming first activity not after coming 3rd activity.

how solve problem?

edit: answers guys,the reply of "ved prakash" solved problem me.but have weird problem now.when press button app exiting app minimized recent apps button coming on screen , exiting.for example,if have opened setting app before opening app,when press button,my app exiting , settings app opening , exiting itself.what might problem?

ok code wrong. if @ activity source, see activity.onbackpressed() calling finish(). if phone call super.onbackpressed() don't need phone call finish. finish() not stopping application, it's stopping current activity. code on 3rd activity strange. trying stop activity , start same activity. want achieve?

if want exit application 3rd activity, need clear backstack. think have problem construction of app.

java android button back

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -