question

Simplify Now, LLC avatar image
Simplify Now, LLC asked

Integration support for MoPub

I suggest putting out an Amazon-developed custom class as required for MoPub integration. As most of my existing apps are based on MoPub, the lack of this support means the beta of Amazon ads was uninteresting to me and makes it a bad business decision to switch more of my apps over to Amazon Ads. When discussing this with one of your evangelists, I pointed to the instructions from MoPub. I know about these. My point is that spending the effort on this isn't a good business decision for small developers. It should be done once and shared. I suggest that an Amazon-supplied solution would make using your ads more accessible.
mobile ads
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bipin@Amazon avatar image
Bipin@Amazon answered
This post has main code snippet and not complete file, This would give a overview of how to use multiple ads together. [b]Integrating MoPub + Amazon Ads + Admob[/b] public class MainActivity extends Activity implements MoPubView.BannerAdListener,com.amazon.device.ads.AdListener,com.google.ads.AdListener{ private static String MY_LOG_TAG = "amzmopub"; private MoPubView moPubView; private static final String APP_ID = "sample-app-v1_pub-2"; // Sample App Key. Replace this variable with your App Key private ViewGroup adViewContainer; // View group to which the ad view will be added private AdLayout amzAdView; // A placeholder for the next ad so we can keep the current ad visible while the next ad loads Context context; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /** * Mopub */ moPubView = (MoPubView) findViewById(R.id.moadview); moPubView.setAdUnitId("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // Enter your Ad Unit ID from www.mopub.com moPubView.loadAd(); moPubView.setBannerAdListener(this); /** * Amazon */ adViewContainer = (ViewGroup)findViewById(R.id.root_layout); AdRegistration.enableLogging(true); AdRegistration.enableTesting(true); try { AdRegistration.setAppKey(APP_ID); } catch (Exception e) { Log.e(LOG_TAG, "Exception thrown: " + e.toString()); return; } LoadAd(); /** * Google */ AdRequest request = new AdRequest(); request.addTestDevice(AdRequest.TEST_EMULATOR); AdView adView = (AdView)this.findViewById(R.id.adView); adView.loadAd(request); } private void LoadAd() { if (amzAdView == null) { // Create and configure a new ad if the next ad doesn't currently exist amzAdView = new AdLayout(this, AdSize.SIZE_320x50); float scale = this.getApplicationContext().getResources().getDisplayMetrics().density; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams((int) (320 * scale), (int) (50 * scale), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); amzAdView.setLayoutParams(layoutParams); // Register our ad handler that will receive call-backs for state changes during the ad life cycle amzAdView.setListener(this); } // Load the ad with the appropriate ad options. AdTargetingOptions adOptions = new AdTargetingOptions(); amzAdView.loadAd(adOptions); } ... @Override public void onAdLoaded(AdLayout adLayout, AdProperties adProperties) { Log.d(LOG_TAG, adProperties.getAdType().toString() + " Ad loaded successfully."); adViewContainer.addView(amzAdView); } ----------------------------------------activity_main.xml------------------------------------------ -------------------------------------Loading Ads from Multiple SDKs----------------------------------------- https://developer.amazon.com/sdk/mobileads/with-other-sdks.html
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Simplify Now, LLC avatar image
Simplify Now, LLC answered
I ended up implementing a custom fallback class similar to the one at https://developer.amazon.com/public/apis/earn/mobile-ads/docs/with-other-sdks. I created one for MoPub, and a similar one for Admob. It doesn't support one of my original concerns - starting all traffic in MoPub (for tracking purposes and to be able to update traffic without re-releasing app), but it gets the job done and isn't too complex.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Avi Parshna avatar image
Avi Parshna answered
Would you mind uploading the files to github?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.