Navigation in Android Mobile Apps

Asked

Viewed 35 times

0

Fala galera.

I have an app posted on Windows Phone where I navigate between pages without having to worry about the history, that is, if the user presses the Windows Phone Back button, it automatically goes back to the previous page. Similar to IE or Firefox, for example.

To be clearer, suppose the Search.xaml page lists the result of a search.

In this result there is a link to the registration details. When user clicks I send it to the page Detail.xaml? id=1

In the details of the page Detail.xaml has another link to another reference. So, I redirect the user to the same page Detail.xaml? id=2.

And so on and so forth.

I get the same result on Android?

Remembering that in WP, I do not care about the history of the pages because it goes back to the previous page without intervention in code.

Hugs.

1 answer

2


Android has a mechanism similar to Windows Phone, the "pages" are stacked so that when you press the back button, the Activity (page) is closed and the previous one is displayed, if you don’t have a previous Activity, the app closes or performs an action (go to the background, for example).

While on Windows Phone you go to another page using the Navigate, on Android, you create a Intent.

    Intent intent = new Intent(AtualActivity.this, ProximaActivity.class);
    startActivity(intent);

Where AtualActivity.this refers to Activity current and ProximaActivity.class refers to Activity where do you want to go.

Hence to return to the previous Activity (page), just call the finish or let the button come back take care of it for you.

    finish();

The passage and return of parameters is done in a similar way.

In short: Navigation works just like Windows Phone.

You can learn more about:

Intents - https://developer.android.com/guide/components/intents-filters.html?hl=pt-br

operation of navigation - https://developer.android.com/guide/components/activities/tasks-and-back-stack.html and https://developer.android.com/training/implementing-navigation/temporal.html (English)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.