我有一个网站,我想在我的网页视图中查看。
我已经创建了一个Web视图的示例应用程序来加载网站的URL。
这是我的活动代码。使用此代码,我将加载其他视频特定的网站,如youtube。从我的桌面浏览器,我可以打开网站,但不能从此活动。我的视频要在我的网站上呈现。
从我的移动Chrome浏览器中,它不能播放,而是从我的浏览器中播放。 我甚至将Web视图的用户代理更改为我的股票浏览器,但结果相同。
package com.example.testcontent;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.webkit.WebSettings;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class WebViewActivity extends Activity
{
private final String TAG = "WebViewActivity";
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
WebView webView = (WebView) findViewById(R.id.webview);
WebSettings webViewSettings = webView.getSettings();
webViewSettings.setJavaScriptEnabled(true);
webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webViewSettings.setPluginState(PluginState.ON);
webView.getSettings().setAllowFileAccess(true);
webView.setSoundEffectsEnabled(true);
webView.setWebViewClient(new WebViewClient());
// webViewSettings
// .setUserAgentString("Mozilla/5.0 (Linux; U; Android 4.4.2; en-in; HTC_One_dual_sim Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
Log.i(TAG, "User Agent used in the web view " + webViewSettings.getUserAgentString());
webView.loadUrl("http://mywebsite.com");
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.web_view, menu);
return true;
}
}
这也是我得到的日志
06-27 17:38:13.458: W/IInputConnectionWrapper(30916): reportFullscreenMode on inactive InputConnection
06-27 17:38:21.877: V/WebViewChromium(31760): Binding Chromium to the background looper Looper (main, tid 1) {41e47bb0}
06-27 17:38:21.877: I/chromium(31760): [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
06-27 17:38:21.877: I/BrowserProcessMain(31760): Initializing chromium process, renderers=0
06-27 17:38:21.897: W/chromium(31760): [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
06-27 17:38:21.907: I/Adreno-EGL(31760): <qeglDrvAPI_eglInitialize:316>: EGL 1.4 QUALCOMM build: (CL4169980)
06-27 17:38:21.907: I/Adreno-EGL(31760): OpenGL ES Shader Compiler Version: 17.01.10.SPL
06-27 17:38:21.907: I/Adreno-EGL(31760): Build Date: 12/25/13 Wed
06-27 17:38:21.907: I/Adreno-EGL(31760): Local Branch:
06-27 17:38:21.907: I/Adreno-EGL(31760): Remote Branch:
06-27 17:38:21.907: I/Adreno-EGL(31760): Local Patches:
06-27 17:38:21.907: I/Adreno-EGL(31760): Reconstruct Branch:
06-27 17:38:21.967: I/WebViewActivity(31760): User Agent used in the web view Mozilla/5.0 (Linux; Android 4.4.2; HTC One dual sim Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
06-27 17:38:22.027: I/InputMethodManager(31760): [startInputInner] EditorInfo { packageName=com.example.testslccontent, inputType=0xa1, imeOptions=0x12000000, privateImeOptions=null }, windowGainingFocus=android.view.ViewRootImpl$W@41ea1b88, mServedView=android.webkit.WebView{41e7a8a0 VFEDHVC. .F....ID 48,48-1032,1653 #7f080000 app:id/webview}
06-27 17:38:22.027: W/AwContents(31760): nativeOnDraw failed; clearing to background color.
06-27 17:38:22.138: I/chromium(31760): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
06-27 17:38:22.168: I/chromium(31760): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
06-27 17:38:22.178: E/qdutils(31760): FBIOGET_FSCREENINFO failed
06-27 17:38:22.238: D/libc(31760): [NET] getaddrinfo+,hn 18(0x70726f78792e62),sn(),family 0,flags 1024
06-27 17:38:22.238: D/libc(31760): [NET] getaddrinfo-, 1
06-27 17:38:22.238: D/libc(31760): [NET] getaddrinfo_proxy+
06-27 17:38:22.238: D/libc(31760): [NET] getaddrinfo_proxy-, success
06-27 17:38:24.020: I/chromium(31760): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
只有错误来自06-27 17:38:22.178:E / qdutils(31760):FBIOGET_FSCREENINFO失败。
我在4.4.2。我的代码是根据API级别19编译的。
欢呼声, Saurav