Go back to android

I am trying to code a reverse key in android to get back to a page that is constantly updating and changing. At the moment, he just comes back with strikes seeing the change.

Here is the code

 @Override
public void onBackPressed() {
// do something on back.
super.loadUrl("file:///android_asset/www/index.html");
return;
}

      

I have also tried

 public boolean onKeyDown(int keyCode, KeyEvent event)  
{  
    //replaces the default 'Back' button action  
    if(keyCode==KeyEvent.KEYCODE_BACK)  
    {  
        //do whatever you want the 'Back' button to do  
        //as an example the 'Back' button is set to start a new Activity named 'NewActivity'  
        super.loadUrl("file:///android_asset/www/index.html");
    }  
    return true;  
}

      

The soft key is located to the right of the phone and does this with the phone connection.

enter image description here

+3


source to share


2 answers


Try giving some random data (or System.currentTimeMillis ()) to the end of the url :-) - after the question mark:

file:///android_asset/www/index.html?hgjhfsd

      



Or try:

super.clearCache();

      

0


source


You can achieve this using javascript. Add an event listener

Add listner



document.addEventListener("backbutton", onBackKeyDown, false);

function onBackKeyDown()
{
     window.location="index.html";
}

      

0


source







All Articles