Prerana
Prerana

Reputation: 115

Inmobi integration with Android APP not showing ads

I have integrated inmobi in my android app. Ads are not coming.

Given below in my MainActivity code and the xml file.

 InMobiSdk.init(MainActivity.this, "5a41560ee01d46c5a38fcd4e56236ff7");
    InMobiSdk.setLogLevel(InMobiSdk.LogLevel.DEBUG);
    InMobiBanner banner = (InMobiBanner)findViewById(R.id.banner);
    banner.load();

The code for XML file is as follows

<com.inmobi.ads.InMobiBanner

    android:id="@+id/banner"
    android:layout_width="320dp"
    android:layout_height="50dp"
    ads:placementId="1479424179204"
    ads:refreshInterval="60"/>

Can any one help me out where I am going wrong. I have specified all the permissions required in manifest file.

Please help me out

Upvotes: 3

Views: 1363

Answers (2)

Raj Suvariya
Raj Suvariya

Reputation: 1664

You should be getting "inMobiBanner could not be initialized. Ignoring your call" in the log message. The common cause of this problem is that you are creating InMobiBanner before calling init on InMobiSdk. If you are adding InMobiBanner in XML then you need to call InMobiSdk.init() before you call setContentView().

Hope this helps!

Upvotes: 1

kartik srivastava
kartik srivastava

Reputation: 103

Add banner in Java code.

 private void addBanner() {
        InMobiBanner bannerAd = new InMobiBanner(this, placement ID);
        RelativeLayout adContainer = findViewById(R.id.banner);
        float density = getResources().getDisplayMetrics().density;
        RelativeLayout.LayoutParams bannerLp = new RelativeLayout.LayoutParams((int) (320 * density), (int) (50 * density));
        adContainer.addView(bannerAd, bannerLp);
        bannerAd.load();
    }

Upvotes: 1

Related Questions