Its every common query how to go back to previous activity.
Most of us will finish activity or keep track of the activity stack and all.
But no need of this type of complex logic if you need just the same effect of user's back key press
You can use the android onBackPressed() method explicitly .
Most of us will finish activity or keep track of the activity stack and all.
But no need of this type of complex logic if you need just the same effect of user's back key press
You can use the android onBackPressed() method explicitly .
super.onBackPressed();
The default implementation simply finishes the current activity, but you can override this to do whatever you want.
The android implicitly call this method when the activity has detected the user's press of the back key.
So calling this explicitly will give the same effect
Hello, actually using that method closes my first activity (in wich i execute that super.onBackPressed();) and not the second activity in wich i dont have access.
ReplyDeleteIn my case, my app work making a call and then i want to bring my onPaused activity to the front again... I mean like not closing the Call, but to show my activity again..
Thanks for your help
Hi fr0st, The default implementation simply finishes the current activity.
ReplyDeleteI didn't get you completely. if you want to call an previous activity without finishing current activity, best thing is start that activity again and you should set the launchMode as singleTask
Sorry english isnt my mother language, but what im trying to say is that:
ReplyDeleteI got myActivity wich in certain part of the code makes a call using:
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+nume));
startActivity(callIntent);
wich then opens up the default dialer and start calling tjat nume number.. i just need that my same myActivity return back to the screen, life if the user in the calling activity pressed back button
So i need to make some code in onPause() that will emulate the user pressing back button but in the calling app of the android (wich of course i dont have access to the code)
Hope you understand me and im really in a hurry with this so an ASAP reply would be appreciated
Like i just need that onBackPressed(); works on the whole system, not only locally at my activity
ReplyDeleteI think in your case it is better to use startActivityForResult, so it will return to onActivityResult
ReplyDeleteAm new to Android, I feel it will be better if u explained the above topic with some Example code.
ReplyDeletehow to link the R.ID.textedit(nuber) in java variable creation of name
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteas I am triggering google map app for navigation..it will take me to navigation screen but while i click on back button it will show two more activity after that it will return back to original user app..can we go into main app in single click??
ReplyDeleteI am using same thing to go back to main activity from another activity but whatever data in main activity is getting vanished and app get start from on create so how do I save my data in main activity while returning back.
ReplyDeleteLovely blog you have heree
ReplyDelete