我已經在我的android應用程序中添加了webbrowser(webview),但是當我例如轉到某個網站時,其中有一個電話或導航按鈕,如Google或電話簿頁面,它只是說不能打開tel:某個號碼。如果是導航按鈕,應打開撥號程序或谷歌地圖。我該如何處理?請幫助Webbrowser android應用程序無法正常工作
代碼:
package com.mysoftware.mysoftwareos.launcher;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class PeopleSearchActivity extends Activity implements OnClickListener {
WebView peoplesearchWebView;
EditText peoplesearchEditText;
Button peopleSearchButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.peoplesearch);
//Import views
peoplesearchWebView = (WebView)findViewById(R.id.peoplesearchWebView);
peoplesearchEditText = (EditText)findViewById(R.id.peoplesearchEditText);
peopleSearchButton = (Button)findViewById(R.id.peopleSearchButton);
//Setup onClickListener for the buttons
peopleSearchButton.setOnClickListener(this);
//Setup WebView
peoplesearchWebView.getSettings().setJavaScriptEnabled(false);
peoplesearchWebView.getSettings().setBuiltInZoomControls(false);
peoplesearchWebView.setWebViewClient(new myWebViewClient());
}
public void onClick(View src) {
switch(src.getId()) {
case R.id.peopleSearchButton:
String searchUrl;
searchUrl = ("http://m.gulesider.no/query?search_word=" + peoplesearchEditText.getText().toString() + "&geo_area=&what=mobwp&hpp=10");
peoplesearchWebView.loadUrl(searchUrl);
}
}
public class myWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(String url, WebView view) {
view.loadUrl(url);
return true;
}
}
}
我已經這樣做了,請查看我的代碼 – user1446632
我沒有看到您的代碼實際處理您提到的任何鏈接。你只是告訴webview加載它,而不管它是什麼類型的鏈接。實際上處理鏈接,或完全刪除您的客戶端,並使用默認 - 這應該處理它們就好了。 – toadzky