0

Hi would like to know how to return back to the app after getting into webview in android.

Java code

package shan.kvb;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class ShanActivity extends Activity {
    /** Called when the activity is first created. */
    WebView mWebView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl("file:///android_asset/index.html");
    }
}

2 Answers2

0

View this answer of mine. In it I describe how to pass values from web view to the android code and from android code to the web view. This works if you are loading the web view from string of your own (you have the power to change). If you just go to random url you can not expect to be able to return back to the android code in any other way than the hardware back button.

Community
  • 1
  • 1
Boris Strandjev
  • 46,145
  • 15
  • 108
  • 135
0
@Override
public void onBackPressed() {
Intent intent = new Intent(ShanActivity.this, ShanActivity.class);
}
Vinit ...
  • 1,409
  • 10
  • 37
  • 66