私は現在、Web サイトに基づく Android アプリケーションに取り組んでいます。iOS アプリケーションは既に存在しており、統一性のためにいくつかのコードを尊重する必要があります。
すべてがほぼ完了しましたが、興味深い問題を発見しました: iframe ビデオ (Youtube、Dailymotion) を含むページに webview (表示されたページを制御することはできません) を使用すると、全画面表示になりません。 、プレーヤーのボタンを押しているのに。
私はすでにここにあるほとんどすべてを試しましたが、表示する必要があるページを知っているアプリのみを参照しています.
アプリの webActivity 部分のコードは次のとおりです。
public class WebActivity extends Activity {
String targetURL = "";
String title = "";
WebView wv;
@Override
public void onResume() { super.onResume(); CookieSyncManager.getInstance().startSync(); }
@Override
public void onPause() { super.onPause(); CookieSyncManager.getInstance().stopSync(); }
/** Called when the activity is first created. */
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
//getWindow().requestFeature(Window.FEATURE_NO_TITLE);
CookieSyncManager.createInstance(getApplicationContext());
CookieSyncManager.getInstance().startSync();
CookieManager.getInstance().setAcceptCookie(true);
/**
* TODO: WebView Cookie management.
* Right now, a cookie is hardcoded here into the WebView instead of getting it from the API called by HttpClient when retrieving the JSON.
* Need to make things cleaner.
*/
CookieManager.getInstance().setCookie("http://www.blabla.fr/mobile/","gbapi=1; Domain=.www.blabla.fr");
/**
* Get parameters
*/
Bundle b = getIntent().getExtras();
if(b != null)
{
targetURL = b.getString("url");
title = b.getString("title");
}
setTitle(title);
setContentView(R.layout.activity_webview);
wv = (WebView) findViewById(R.id.webview);
WebSettings wvSettings = wv.getSettings();
// WebView options
wvSettings.setDefaultTextEncodingName("utf-8");
wvSettings.setJavaScriptEnabled(true);
wvSettings.setPluginState(PluginState.ON);
wvSettings.setJavaScriptCanOpenWindowsAutomatically(true);
wvSettings.setBuiltInZoomControls(true);
final Activity activity = this;
wv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setProgress(progress * 100);
}
});
wv.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, "Oh snap! " + description, Toast.LENGTH_SHORT).show();
}
});
wv.loadUrl(targetURL);
}
}
助けてくれてありがとう。