Reputation: 141
I'm creating a Phonegap Android application, I've placed a Youtube Iframe inside a webview. But when playing a video only the sound works and the screen stays black.
I've found a solution, but I can't seem to get it working. I've got to add the code "getSettings().setPluginsEnabled(true);" inside App.java. Does anyone know how to implement this code?
App.java
package com.package.name;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.os.Handler;
import android.widget.LinearLayout;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
public class App extends DroidGap {
private Handler mHandler = new Handler();
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
mHandler.postDelayed(new Runnable() {
public void run() {
doAdMob();
}
}, 1000);
}
private void doAdMob() {
adView = new AdView(this, AdSize.BANNER, "CODE");
LinearLayout layout = super.root;
layout.addView(adView);
layout.setHorizontalGravity(android.view.Gravity.CENTER_HORIZONTAL);
AdRequest request = new AdRequest();
adView.loadAd(request);
}
}
Thank you very much in advance.
Upvotes: 3
Views: 1759
Reputation: 23273
In your onCreate method is where you need to add the line:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
this.appView.getSettings().setPluginsEnabled(true);
mHandler.postDelayed(new Runnable() {
public void run() {
doAdMob();
}
}, 1000);
}
Upvotes: 2