327
Views
10
Comments
How to clear mobile screen from back stack
Question

I want to clear all of navigation history of my application mobile and, return to the first screen when I click on a logout button. It would has any plugin in the Outsystems to do that?

2026-02-26 06-29-24
Rahul
 
MVP

Raj008 wrote:

I want to clear all of navigation history of my application mobile and, return to the first screen when I click on a logout button. It would has any plugin in the Outsystems to do that?

Hi Raj,


You can simple do that using Jquery or javascript .

<script type="text/javascript" >   function preventBack(){window.history.forward();}    setTimeout("preventBack()", 0);    window.onunload=function(){null};</script>


UserImage.jpg
Raj008

Rahul Sahu wrote:

Raj008 wrote:

I want to clear all of navigation history of my application mobile and, return to the first screen when I click on a logout button. It would has any plugin in the Outsystems to do that?

Hi Raj,


You can simple do that using Jquery or javascript .

<script type="text/javascript" >   function preventBack(){window.history.forward();}    setTimeout("preventBack()", 0);    window.onunload=function(){null};</script>


Thank you for quick update.

This code is not working on my OutSystems Mobile app. Here is the scenario


  1. Login to app in Android device.
  2. Logout from the app.
  3. Re- login into app and then logout.
  4. Now tap the device back button from the Login screen.  Is showing previous login screen two times( How many times you visited )

Here I need solution, how can clear previous screen stack before logout .


Thanks in advanced.

  


UserImage.jpg
Miguel Angel Beltran Vargas

Kumar,

Where I put tha JavaScritp, on Initialize event?

2020-09-17 01-03-04
Koushik Prathi

Hi Raj008,

I also faced the same issue with login page, After user login if you press the back button it will take you to the loagin screen again. Even if you are already login.

I resolved this issue, By using GetUserId() Function value on the OnIntialize Action of the login screen. If i get the userid from the GetUserId() function then,I use the java script to force close the app.

Attaching sample oml file,for reference.

Hope this will helps you.

Regards,

Koushik

SampleLoginBackButton.oml
UserImage.jpg
Raj008

Koushik Prathi wrote:

Hi Raj008,

I also faced the same issue with login page, After user login if you press the back button it will take you to the loagin screen again. Even if you are already login.

I resolved this issue, By using GetUserId() Function value on the OnIntialize Action of the login screen. If i get the userid from the GetUserId() function then,I use the java script to force close the app.

Attaching sample oml file,for reference.

Hope this will helps you.

Regards,

Koushik


Thank you for update.

In my case Multiple login pages are creating as stack.  Single Stack should maintain.


Thanks,

Rajesh R.

2020-09-17 01-03-04
Koushik Prathi

The sample I provided will also work fine. with your scenario.Just give it a try.


UserImage.jpg
Raj008

Koushik Prathi wrote:

The sample I provided will also work fine. with your scenario.Just give it a try.


Hi Koushik,

Your given code is working fine, but I need login page should be there. Given code exit the application completely. 


2020-09-17 01-03-04
Koushik Prathi

Hi Raj008,

Once the user is already login why we need to show him the login page again, if you provide some more info it will help me,like scenario.

Regards,

Koushik

UserImage.jpg
Raj008

Koushik Prathi wrote:

Hi Raj008,

Once the user is already login why we need to show him the login page again, if you provide some more info it will help me,like scenario.

Regards,

Koushik

Hi Koushik,

Thank you for  reply.

If I navigate from Login -> A -> B -> C ->  then select the "Logout" option from the menu, then I should be navigated to the Login page without back stack.

I want clear navigation back history.

Thanks,

Rajesh R


2023-08-01 16-31-38
Nagaraju Gaddam

This can be done in multiple ways.


1. The easiest way is to relaunch the app by using following Javascript code

window.open($public.BuiltinFunctions.getOwnerURLPath()+"Screen,Name"_self");

2.  Use below cordova code  

if (navigator.app) {navigator.app.exitApp();}else if (navigator.device) {  navigator.device.exitApp();}else {          window.close();}

3.  If your screen already in the stack but not immediate back. Use below

window.history.go(-2); //second screen from top



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.