我研究了很多,但没有找到任何工作,我希望我的webview打开桌面版本而不是html页面的移动版本......这样做的方法是什么?
这是我的代码:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.jobs);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
Window.PROGRESS_VISIBILITY_ON);
getActionBar().setDisplayHomeAsUpEnabled(true);
jwv = (WebView) findViewById(R.id.jobsweb);
jwv.loadUrl("https://2ce74af0d8de8783b91cdd315eeba0340a4b9277.googledrive.com/host/0B2sDUzNeIK0KODB0ZDRMVjFPaFE/Jobs.html");
String ua = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
jwv.getSettings().setUserAgentString(ua);
jwv.setWebViewClient(new WebViewClient()
{
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(Jobs.this, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
final Activity MyActivity = this;
jwv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
MyActivity.setTitle("Loading...");
MyActivity.setProgress(progress * 100);
if (progress == 100)
MyActivity.setTitle("Jobs");
}
});
}
答案 0 :(得分:0)
你的问题在那里:
String ua = "Mozilla/5.0 (Linux; U; Android 3.1; en-US; GT-P7500 Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Desktop Safari/534.13";
mWebview.getSettings().setUserAgentString(ua);
它是一个Android 3.1用户代理!
请改用此用户代理:
String ua = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";