Задать вопрос
@TheDoctor

Android studio. Как запретить возврат на активность?

Здравствуйте.
Как запретить возврат на первую активность?
В моём случаи это форма авторизации.
  • Вопрос задан
  • 1618 просмотров
Подписаться 2 Оценить Комментировать
Помогут разобраться в теме Все курсы
  • AndroidSprint
    Android + Аутстаффинг: опыт работы в IT-команде
    8 месяцев
    Далее
  • Нетология
    Android-разработчик
    14 месяцев
    Далее
  • Академия Эдюсон
    Android-разработчик: тариф Базовый
    6 месяцев
    Далее
Решения вопроса 2
@LenLord
android reverse
https://stackoverflow.com/questions/1898886/removi...
первый ответ в гугле )

You can achieve this by setting the android:noHistory attribute to "true" in the relevant entries in your AndroidManifest.xml file. For example:

<activity
    android:name=".AnyActivity"
    android:noHistory="true" />
Ответ написан
@subway
Есть два способа. Первый это когда с первой активити запускаете второе добавить finish
startActivity(new Intent(FirstActivity.this, SecondActivity.class));
finish();


Второй способ добавить флаги
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();

Подробнее:
https://developer.android.com/reference/android/co...
This launch mode can also be used to good effect in conjunction with FLAG_ACTIVITY_NEW_TASK: if used to start the root activity of a task, it will bring any currently running instance of that task to the foreground, and then clear it to its root state. This is especially useful, for example, when launching an activity from the notification manager.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы