【问题标题】:how to get json response in webview如何在 webview 中获取 json 响应
【发布时间】:2017-02-10 15:10:58
【问题描述】:
 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    activity = this;
    mContext = getApplicationContext();
    util = new Login_Utils(mContext, activity);

    Intent intent = getIntent();
    url = intent.getExtras().getString("url");

    webView = (WebView)findViewById(R.id.webview_Login);
    webView.setWebViewClient(new WebViewClient(){

        @Override
        public boolean shouldOverrideUrlLoading (WebView view, String url) {

            return false;
        }


        public void onPageFinished(WebView view, String urlConnection){

        }
    });
    webView.loadUrl(url);

}

我的应用有 2 种登录方式。 1.在应用程序中创建帐户并登录 2. 用知名网站(facebook等)登录

如果我尝试使用方法 2 登录,webview 会显示网站的登录屏幕。 (实现登录机制所需的所有工作都在服务器端完成)

如果 id 和密码匹配,服务器会以 json 格式返回一些信息。

所以,我想获取 json 对象。

【问题讨论】:

    标签: android


    【解决方案1】:

    让我试着解释一下。如果您正在调用您的 URL,那么您可以得到如下响应: How can I get the JSON response of a POST request in a WebView? 检查它并尝试使用WebViewClientshouldOverrideUrlLoading 方法。 也许对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-24
      • 2019-11-21
      相关资源
      最近更新 更多