I tried using a banner AdMob ad with using these hint android.googleAdUnitId and i need to add something like these features on this ad
firstly: the background color of ad is black and I need to replace it to white secondly: the ad will appear starting from splash screen and that it's not beautiful. I want to avoid appear it on this form. thirdly: I want to specify the location of the ad between component how can i make all these things as native code with using native interface? i see this topic for add banner in android studio without using xml file https://stackoverflow.com/questions/43275336/android-how-to-display-ad-only-using-java-and-not-xml and i writen these code as native code package com.soft.test; import com.codename1.impl.android.AndroidNativeUtil; import android.app.Activity; import android.content.Context; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.MobileAds; import com.google.android.gms.ads.AdView; import com.google.android.gms.ads.AdSize; import android.widget.LinearLayout; import android.view.Gravity; public class BannerInterImpl { Context context = AndroidNativeUtil.getContext(); Activity activity = AndroidNativeUtil.getActivity(); public void showBannerAd(String id) { //Add this wherever your code needs to add the ad LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); //Additionally to adjust the position to Bottom layout.setGravity(Gravity.BOTTOM); // Create a banner ad AdView mAdView = new AdView(context); mAdView.setAdSize(AdSize.SMART_BANNER); mAdView.setAdUnitId("ca-app-pub-3940256099942544/6300978111"); // Create an ad request. AdRequest.Builder adRequestBuilder = new AdRequest.Builder(); // Optionally populate the ad request builder. adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR); // Add the AdView to the view hierarchy. layout.addView(mAdView); // Start loading the ad. mAdView.loadAd(adRequestBuilder.build()); activity.setContentView(layout); } public void initAd() { MobileAds.initialize(context, "ca-app-pub-3940256099942544/6300978111"); } public boolean isSupported() { return true; } } and this in the main class Form hi = new Form("Hi World", BoxLayout.y()); hi.add(new Label("Hi World")); hi.show(); banner.initAd(); banner.showBannerAd(""); but that doesn't work and app will not add the ad on the main class -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/codenameone-discussions. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/b7496504-d3e9-43d8-90b8-dcfbdce37c39%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
