【问题标题】:Android: Navigation from Webview to AppAndroid:从 Webview 导航到 App
【发布时间】:2012-03-15 15:04:16
【问题描述】:

您好想知道在android中进入webview后如何返回应用程序。

Java 代码

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");
    }
}

【问题讨论】:

    标签: android


    【解决方案1】:

    查看mine的这个答案。在其中,我描述了如何将值从 web 视图传递到 android 代码以及从 android 代码传递到 web 视图。如果您从自己的字符串加载 Web 视图(您有权更改),则此方法有效。如果你只是去随机 url,你不能指望能够以硬件返回按钮以外的任何其他方式返回到 android 代码。

    【讨论】:

      【解决方案2】:
      @Override
      public void onBackPressed() {
      Intent intent = new Intent(ShanActivity.this, ShanActivity.class);
      }
      

      【讨论】:

        猜你喜欢
        • 2012-06-26
        • 1970-01-01
        • 1970-01-01
        • 2019-03-13
        • 1970-01-01
        • 2014-07-08
        • 1970-01-01
        • 2020-12-23
        • 2011-10-24
        相关资源
        最近更新 更多