The code to show the map works correctly, but when I want to return to my application by pressing the "back" button, the application starts again on the screen that I raised the map and consequently an error is generated, how could I solve it?
Uri intentUri = Uri.parse("geo:41.382,2.170?z=16&q=41.382,2.170(Esta+Es+La+Etiqueta)");
Intent intent = new Intent(Intent.ACTION_VIEW, intentUri);
startActivity(intent);
greetings and thank you very much
If you don't want to keep the Activity that opened the map, add
finish()
to terminate the Activity:With this you could avoid the error, but you have a problem when you return to the activity that made the intent. You probably have a problem in
onResume()
uonStart()
if you are using these methods.There shouldn't be an error as such, in fact what you mention is not a problem.
The screens in an app are like cards that you place one on top of the other as you open them. In other words, when you start your application you put a card on the table, then from that card you open a map (map card) and it goes on to be placed on top of the previous card.
If you decide to close the map, the previous card is still there and will logically be shown.
Graphically it is this, you open a new activity without closing the previous one
What you should do is call
finish()
and the previous activity disappears from the stackWhen you open another screen (
Activity
) and you don't want the caller to see it again, you must call the methodfinish()
on the activity that calls the new activity.The true error in your case (which you mentioned happens) we can't know if you don't put the error trace that appears in your
Logcat
.Please, if the matter is still bothering you, post the trace of the error and we can help you better.