Can I Display Google Adwords (adview) In Javafx On Android
I have a javafx app running on android and would like to place google adwords on some of the screens. The issue I have is that the adwords use googles AdView to display the add wh
Solution 1:
You can easily include an AdView
in your app by getting access to the ViewGroup
from the FXActivity
.
This is a code snippet that works for me. Notice it has to run in the UIThread:
publicAndroidAds() {
FXActivity.getInstance().runOnUiThread(() -> {
LinearLayoutlayout=newLinearLayout(FXActivity.getInstance());
layout.setVerticalGravity(Gravity.BOTTOM);
layout.setOrientation(LinearLayout.VERTICAL);
AdViewadView=newAdView(FXActivity.getInstance());
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId("ca-app-pub-XXXXXXXXXXXXXXXXXXXX");
AdRequestadRequest=newAdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("XXXXXXXXXXXXXXXXXXXX")
.build();
adView.loadAd(adRequest);
adView.setAdListener(newAdListener() {
@OverridepublicvoidonAdLoaded() {
super.onAdLoaded();
System.out.println("AD loaded");
}
});
layout.addView(adView);
FXActivity.getViewGroup().addView(layout);
});
}
Post a Comment for "Can I Display Google Adwords (adview) In Javafx On Android"