Hello,
For preventing the back key from returning, in Android you can achieve this by rewriting OnBackPressed.
Please refer to the key snippets below:
For activity1:
Intent intent = new Intent(this, typeof(Activity1));
// Declare that this navigation stack currently has two activities when the page jumps
intent.PutExtra("stack_count", 1);
StartActivity(intent);
For Activity2:
// If this activity is second, the back event is not triggered.
public override void OnBackPressed()
{
int count = Intent.GetIntExtra("stack_count", 0);
if (count < 1)
{
base.OnBackPressed();
}
}
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.