Admob Ads are not showing in some of the fragments in the android App

2,246 views
Skip to first unread message

Priyanka Roy

unread,
Dec 7, 2015, 1:18:48 PM12/7/15
to Google Mobile Ads SDK Developers
I am making an that app is integrated with Admob ads. The application has multiple screens made of activities and fragments. Admob ad is showing only at one place and its not show at rest of the places. I am not able understand why?

Logcat Output:-

    12-07 23:27:28.856 1715-1715/? W/dex2oat: Compilation of void com.google.android.ads.zxxz.a.<init>() took 812.350ms
   
12-07 23:27:28.926 1667-1679/? I/art: Background partial concurrent mark sweep GC freed 2941(143KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 3MB/6MB, paused 12.169ms total 199.192ms
   
12-07 23:27:28.993 1715-1715/? W/dex2oat: Compilation of int com.google.android.ads.zxxz.a.a(android.content.Context) took 136.555ms
   
12-07 23:27:29.307 1715-1715/? I/dex2oat: dex2oat took 1.883s (threads: 1) arena alloc=39KB java alloc=12KB native alloc=458KB free=3MB
   
12-07 23:27:29.772 1667-1679/? I/art: Background sticky concurrent mark sweep GC freed 8564(541KB) AllocSpace objects, 18(560KB) LOS objects, 13% free, 5MB/6MB, paused 5.421ms total 169.146ms
   
12-07 23:27:29.969 1667-1727/? W/GooglePlayServicesUtil: Google Play services out of date.  Requires 8115000 but found 6774430
   
12-07 23:27:29.981 1667-1727/? E/GooglePlayServicesUtil: GooglePlayServices not available due to error 2
   
12-07 23:27:30.030 1667-1728/? W/GooglePlayServicesUtil: Google Play services out of date.  Requires 8115000 but found 6774430
   
12-07 23:27:30.046 1667-1728/? E/GooglePlayServicesUtil: GooglePlayServices not available due to error 2
   
12-07 23:27:31.047 1667-1679/? I/art: Background partial concurrent mark sweep GC freed 3535(296KB) AllocSpace objects, 15(631KB) LOS objects, 39% free, 5MB/9MB, paused 4.880ms total 135.956ms
   
12-07 23:27:33.099 1667-1731/? I/Ads: Not on service, return
   
12-07 23:27:33.127 1667-1732/? I/Ads: Not on service, return
   
12-07 23:27:33.235 1667-1679/? I/art: Background sticky concurrent mark sweep GC freed 10582(805KB) AllocSpace objects, 31(960KB) LOS objects, 15% free, 8MB/9MB, paused 5.704ms total 111.054ms
   
12-07 23:27:33.540 1667-1667/? W/chromium: [WARNING:data_reduction_proxy_settings.cc(331)] SPDY proxy OFF at startup
   
12-07 23:27:33.637 1667-1667/? W/art: Attempt to remove local handle scope entry from IRT, ignoring
   
12-07 23:27:33.687 1667-1667/? W/AwContents: onDetachedFromWindow called when already detached. Ignoring
   
12-07 23:27:33.759 1667-1667/? W/art: Attempt to remove local handle scope entry from IRT, ignoring
   
12-07 23:27:33.760 1667-1667/? W/art: Attempt to remove local handle scope entry from IRT, ignoring
   
12-07 23:27:34.773 1667-1667/? W/art: Attempt to remove local handle scope entry from IRT, ignoring
   
12-07 23:27:34.798 1667-1667/? W/AwContents: onDetachedFromWindow called when already detached. Ignoring
   
12-07 23:27:34.863 1667-1667/? W/art: Attempt to remove local handle scope entry from IRT, ignoring
   
12-07 23:27:34.863 1667-1667/? W/art: Attempt to remove local handle scope entry from IRT, ignoring
   
12-07 23:27:37.363 1667-1667/? I/chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
   
12-07 23:27:37.386 1667-1667/? I/chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
   
12-07 23:27:38.685 1667-1679/? I/art: Background sticky concurrent mark sweep GC freed 11420(701KB) AllocSpace objects, 3(64KB) LOS objects, 6% free, 9MB/9MB, paused 4.324ms total 352.051ms
   
12-07 23:27:41.639 1667-1667/? I/chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
   
12-07 23:27:41.657 1667-1667/? I/chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
   
12-07 23:27:41.837 1667-1667/? I/chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
   
12-07 23:27:41.844 1667-1667/? I/chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0)
   
12-07 23:27:42.275 1667-1679/? I/art: Background sticky concurrent mark sweep GC freed 5532(337KB) AllocSpace objects, 1(32KB) LOS objects, 4% free, 9MB/9MB, paused 3.745ms total 140.653ms
   
12-07 23:27:43.381 1667-1732/? W/Ads: There was a problem getting an ad response. ErrorCode: 0
   
12-07 23:27:43.387 1667-1667/? W/Ads: Failed to load ad: 0
   
12-07 23:27:45.625 1667-1679/? W/art: Suspending all threads took: 249.850ms



Fragment_gallery_grid.xml

    <?xml version="1.0" encoding="utf-8"?>
   
   
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       
xmlns:tools="http://schemas.android.com/tools"
       
android:layout_width="match_parent"
       
android:layout_height="match_parent"
       
android:paddingLeft="0dp"
       
android:paddingRight="0dp"
       
android:paddingTop="0dp"
       
android:paddingBottom="0dp"
       
xmlns:ads="http://schemas.android.com/apk/res-auto"
       
android:orientation="vertical">
   
   
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
       
xmlns:ads="http://schemas.android.com/apk/res-auto"
       
android:id="@+id/grid"
       
android:layout_width="match_parent"
       
android:layout_height="match_parent"
       
android:numColumns="1"
       
android:padding="8dp"
       
android:horizontalSpacing="8dp"
       
android:clipToPadding="true"
       
android:verticalSpacing="8dp"
       
android:scrollbarStyle="outsideOverlay"
       
android:layout_above="@+id/adView" >
   
   
   
</GridView>
   
       
<com.google.android.gms.ads.AdView
           
android:id="@+id/adView"
           
android:layout_width="match_parent"
           
android:layout_height="wrap_content"
           
android:layout_alignParentBottom="true"
           
ads:adSize="BANNER"
           
ads:adUnitId="@string/banner_ad_unit_id"
           
android:layout_alignParentLeft="true"
           
android:layout_alignParentStart="true"
           
android:layout_alignParentRight="true"
           
android:layout_alignParentEnd="true">
       
</com.google.android.gms.ads.AdView>
   
 
   
</RelativeLayout>



gallary_thumbnail.xml

    <?xml version="1.0" encoding="utf-8"?>
   
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       
xmlns:ads="http://schemas.android.com/apk/res-auto"
       
android:orientation="vertical"
   
   
       
android:layout_width="match_parent"
       
android:layout_height="match_parent">
   
       
<TextView
           
android:layout_width="match_parent"
           
android:layout_height="match_parent"
           
android:textAppearance="?android:attr/textAppearanceLarge"
           
android:id="@+id/textView"
           
android:textColor="#304f9f"
           
android:textColorHighlight="#304f9f"
           
android:textStyle="bold"
           
android:textSize="15sp"
           
android:layout_alignParentTop="true"
           
android:layout_alignParentLeft="true"
           
android:layout_alignParentStart="true"/>
   
       
<ViewFlipper
           
android:id="@+id/viewFlipper"
           
android:layout_width="match_parent"
           
android:layout_height="match_parent"
           
android:layout_below="@+id/textView"
           
>
   
       
<ImageView
           
android:id="@+id/image1"
           
android:layout_width="match_parent"
           
android:layout_height="match_parent"
           
android:adjustViewBounds="true"
   
           
>
       
</ImageView>
   
       
<ImageView
           
android:id="@+id/image2"
           
android:layout_width="match_parent"
           
android:layout_height="match_parent"
           
android:adjustViewBounds="true"
           
>
       
</ImageView>
   
       
<ImageView
           
android:id="@+id/image3"
           
android:layout_width="match_parent"
           
android:layout_height="match_parent"
           
android:adjustViewBounds="true"
           
>
       
</ImageView>
   
       
<ImageView
           
android:id="@+id/image4"
           
android:layout_width="match_parent"
           
android:layout_height="match_parent"
           
android:adjustViewBounds="true"
           
>
       
</ImageView>
   
           
<ImageView
               
android:id="@+id/image5"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image6"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image7"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image8"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image9"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image10"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image11"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image12"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image13"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image14"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
           
<ImageView
               
android:id="@+id/image15"
               
android:layout_width="match_parent"
               
android:layout_height="match_parent"
               
android:adjustViewBounds="true"
               
>
           
</ImageView>
   
       
</ViewFlipper>
   
   
</RelativeLayout>


gallary_fragment:-


     
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
   
            position
= getArguments().getInt(ARG_POSITION);
   
           
super.onViewCreated(view, savedInstanceState);
   
            mGridView
= (GridView) view.findViewById( R.id.grid );
            mGridView
.setOnItemClickListener( this );
            mGridView
.setDrawSelectorOnTop( true );
   
           
AdView mAdView = (AdView) view.findViewById(R.id.adView);
           
//AdRequest adRequest = new AdRequest.Builder().build();
           
//AdRequest adRequest = new
           
AdRequest request = new AdRequest.Builder()
                   
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)      
                   
.build();
   
            mAdView
.loadAd(request);
       
}


I have tried removing padding. Please help me resolve the issue. I have read similar issue on this forum but nothing helped. 


AndroidMenifest.xml

    <?xml version="1.0" encoding="utf-8"?>
   
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
       
xmlns:tools="http://schemas.android.com/tools"
       
package="com.invensini.newhindisongs" >
   
       
<uses-feature
           
android:glEsVersion="0x00020000"
           
android:required="true" />
   
       
<uses-permission android:name="android.permission.INTERNET" />
       
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
       
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
   
       
<application
           
android:allowBackup="true"
           
android:hardwareAccelerated="true"
           
android:icon="@mipmap/ic_launcher"
           
android:label="@string/app_name"
           
android:theme="@style/AppTheme"
           
android:logo="@drawable/baricon"
           
tools:replace="icon" >
           
<activity
               
android:name=".activities.MainActivity"
               
android:label="@string/app_name"
               
android:launchMode="singleTop" >
           
</activity>
           
<activity
               
android:name=".activities.TextTutorials"
               
android:parentActivityName=".activities.MainActivity"
               
android:screenOrientation="portrait" >
               
<meta-data
                   
android:name="android.support.PARENT_ACTIVITY"
                   
android:value=".activities.MainActivity" />
           
</activity>
           
<activity
               
android:name=".activities.GalleryDetailActivity"
               
android:parentActivityName=".activities.MainActivity" >
               
<meta-data
                   
android:name="android.support.PARENT_ACTIVITY"
                   
android:value=".activities.MainActivity" />
           
</activity>
           
<activity
               
android:name=".activities.webView"
               
android:hardwareAccelerated="true"
               
android:label="@string/title_activity_web_view"
               
android:parentActivityName=".activities.MainActivity" >
               
<meta-data
                   
android:name="android.support.PARENT_ACTIVITY"
                   
android:value=".activities.MainActivity" />
           
</activity>
           
<activity
               
android:name=".activities.AboutUs"
               
android:label="@string/title_activity_about_us"
               
android:parentActivityName=".activities.MainActivity" >
               
<meta-data
                   
android:name="android.support.PARENT_ACTIVITY"
                   
android:value=".activities.MainActivity" />
           
</activity>
           
<activity
               
android:name=".activities.RateUs"
               
android:label="@string/title_activity_rate_us" >
           
</activity>
           
<activity
               
android:name=".activities.PlayListActivity"
               
android:label="@string/title_activity_play_list"
               
android:parentActivityName=".activities.MainActivity" >
               
<meta-data
                   
android:name="android.support.PARENT_ACTIVITY"
                   
android:value=".activities.MainActivity" />
           
</activity>
           
<activity
               
android:name=".activities.SplashScreen"
               
android:label="@string/title_activity_splash_screen" >
               
<intent-filter>
                   
<action android:name="android.intent.action.MAIN" />
   
                   
<category android:name="android.intent.category.LAUNCHER" />
               
</intent-filter>
           
</activity>
           
<activity
               
android:name=".activities.TrendingActivity"
               
android:label="@string/title_activity_trending"
               
android:parentActivityName=".activities.MainActivity" >
               
<meta-data
                   
android:name="android.support.PARENT_ACTIVITY"
                   
android:value=".activities.MainActivity" />
           
</activity>
           
<activity
               
android:name=".activities.PrivacyPolicy"
               
android:label="@string/title_activity_privacy_policy"
               
android:parentActivityName=".activities.MainActivity" >
               
<meta-data
                   
android:name="android.support.PARENT_ACTIVITY"
                   
android:value=".activities.MainActivity" />
           
</activity>
           
<activity
               
android:name=".activities.Terms"
               
android:label="@string/title_activity_terms"
               
android:parentActivityName=".activities.MainActivity" >
               
<meta-data
                   
android:name="android.support.PARENT_ACTIVITY"
                   
android:value=".activities.MainActivity" />
           
</activity>
           
<meta-data
               
android:name="com.google.android.gms.version"
               
android:value="@integer/google_play_services_version" />
   
           
<activity
               
android:name="com.google.android.gms.ads.AdActivity"
               
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
       
</application>
   
    </manifest

>

Google Play Library:-

   compile 'com.android.support:appcompat-v7:21.0.3'
   compile
'com.google.android.gms:play-services-ads:8.1.0'


Please help.

Veer Arjun Busani

unread,
Dec 7, 2015, 4:51:05 PM12/7/15
to Google Mobile Ads SDK Developers
Hi Priyanka,

After analyzing your code I have couple of suggestions to make, which might help you - 
  • Firstly, could you update the play service library to its current version of 8.3. You can modify the Gradle file to include -  
        compile 'com.google.android.gms:play-services-ads:8.3.0'
This would eliminate the "Google Play services out of date.  Requires 8115000 but found 6774430" error found in your log.
  • Next, the Fragment_gallery_grid.xml is the only place where you have added the AdView and loading one using its corresponding class gallary_fragment. I do not see another AdView in any of the resource or class files. If you want to show multiple ads, you can do so by placing and requesting the AdView for each of the positions. 
  • Finally, if you want to have an AdView for the each of the view in the ViewFlipper, I'd suggest having the desired number of AdViews to be included within the ViewFlipper itself.
Do let us know if you are able to solve the issue. If not do get back to us with sample app and letting us know where all you want the AdView to be placed and we would do so.

Thanks,
Veer Arjun Busani
Mobile Ads SDK Team

Priyanka Roy

unread,
Dec 9, 2015, 9:35:38 AM12/9/15
to Google Mobile Ads SDK Developers
Hi Veer,

I have updated the library, but problem still persist. I have attached two screen shots.

1. Screenshot_2015_12_09 -  Correctly, displays the admob ad

2. Screenshot 2 - shows the main screen and area marked with black rectangle shows where i would like ad to appear.

I am using the similar code for both in the same app. one is working fine another is not. Some how i doubt layout, because it once  showed the ad when 
i placed the at the middle of the screen. Please review the code snippet already shared.

Please let me know if anything else is needed to debug the same.

Priyanka Roy.




...
Screenshot_2.png
Screenshot_2015-12-09-19-46-46.png

Veer Arjun Busani

unread,
Dec 9, 2015, 12:23:35 PM12/9/15
to Google Mobile Ads SDK Developers
Hi Priyanka,

I see that you're trying to have a Banner AdView in the ViewFlipper. Here is a sample code that could work in your case - 

Let's say that in you ViewFlipper activity, which has two LinearLayout that can be flipped, you want to have an AdView after the first ImageView. You need to add the AdView for each instance like adView1 and adView2

<ViewFlipper
        android:id="@+id/viewflipper"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_margin="6dp" >
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>

            <com.google.android.gms.ads.AdView
                android:id="@+id/adView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                ads:adSize="BANNER"
                ads:adUnitId="@string/banner_ad_unit_id">

            </com.google.android.gms.ads.AdView>

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <com.google.android.gms.ads.AdView
                android:id="@+id/adView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                ads:adSize="BANNER"
                ads:adUnitId="@string/banner_ad_unit_id">

            </com.google.android.gms.ads.AdView>

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>
    </ViewFlipper>
Then in your class you need to request and load for each of those instances like this - 

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        viewFlipper = (ViewFlipper) findViewById(R.id.viewflipper);

        AdView mAdView1 = (AdView) findViewById(R.id.adView1);
        AdRequest adRequest1 = new AdRequest.Builder().build();
        mAdView1.loadAd(adRequest1);

        AdView mAdView2 = (AdView) findViewById(R.id.adView2);
        AdRequest adRequest2 = new AdRequest.Builder().build();
        mAdView2.loadAd(adRequest2);
    }
Unless you add AdView into every instance of where you want them to be, they would not appear. Do let us know if you were able to resolve the issue.

Thanks,
Veer Arjun Busani
Mobile Ads SDK Team


...

Priyanka Roy

unread,
Dec 9, 2015, 5:29:16 PM12/9/15
to Google Mobile Ads SDK Developers
Hi Veer,

I just want ads to appear at the bottom of each activity activity. I am able to successfully do it for playlist activity.

But in all other activities its not working. Let's take more simple activity where ad is not getting displayed as well.


activity_trending_fragment:-

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"

xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context="com.invensini.funnyvideos.fragments.TrendingFragment"

 
>

<GridView xmlns:android="http://schemas.android.com/apk/res/android"
 
xmlns:ads="http://schemas.android.com/apk/res-auto"
 
android:id="@+id/grid"
 
android:layout_width="match_parent"
 
android:layout_height="match_parent"
 
android:numColumns="1"

 
android:verticalSpacing="8dp"
 
android:horizontalSpacing="8dp"
 
android:padding="8dp"
 
android:scrollbarStyle="outsideOverlay"
 
android:clipToPadding="true">



</GridView>


<com.google.android.gms.ads.AdView
 
android:id="@+id/adView"
 
android:layout_width="match_parent"
 
android:layout_height="wrap_content"
 
android:layout_alignParentBottom="true"

 
ads:adSize="BANNER"
 
ads:adUnitId="@string/banner_ad_unit_id"

 
android:layout_alignParentLeft="true"
 
android:layout_alignParentStart="true"
 
android:layout_alignParentRight="true"
 
android:layout_alignParentEnd="true">
</com.google.android.gms.ads.AdView>

</RelativeLayout>

CommonFragment.java:-

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

mGridView = (GridView) view.findViewById( R.id.grid );
mGridView.setOnItemClickListener( this );
    mGridView.setOnItemLongClickListener(this);
    mGridView.setDrawSelectorOnTop( true );

AdView mAdView = (AdView) view.findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();


mAdView.loadAd(adRequest);

}

This is a common fragment that is called from the main activity:-


pager
= (ViewPager) findViewById(R.id.viewpager);

slidingTabLayout
= (SlidingTabLayout) findViewById(R.id.sliding_tabs);
pager
.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(), titles));

pager
.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
 
@Override
 
public void onPageSelected(int position) {

 
 
if (position == 0) {
 getSupportFragmentManager
().beginTransaction().replace( R.id.container, GalleryFragment.getInstance(position) ).commit();

 
}else if (position == 1){
 getSupportFragmentManager
().beginTransaction().replace( R.id.container, TextTutorialFragment.getInstance(position) ).commit();

 
}else if (position == 2) {
 getSupportFragmentManager
().beginTransaction().replace( R.id.container, CommonFragment.getInstance("path_to_json1") ).commit();

 
} else if (position == 3) {
 getSupportFragmentManager
().beginTransaction().replace( R.id.container, CommonFragment.getInstance("path_to_json2") ).commit();
 
} else if (position == 4) {
 getSupportFragmentManager
().beginTransaction().replace( R.id.container, CommonFragment.getInstance("path_to_json3") ).commit();

 
}else if (position == 5) {
 getSupportFragmentManager
().beginTransaction().replace( R.id.container, CommonFragment.getInstance("path_to_json4") ).commit();

 
}else if (position == 6) {
 getSupportFragmentManager
().beginTransaction().replace( R.id.container, CommonFragment.getInstance("path_to_json5") ).commit();

 
}else if (position == 7) {
 getSupportFragmentManager
().beginTransaction().replace( R.id.container, CommonFragment.getInstance(""path_to_json6") ).commit();

 }

 else{
 getSupportFragmentManager().beginTransaction().replace( R.id.container, GalleryFragment.getInstance(position) ).commit();

 }

 
 }



CommonAdapter.java:-


public class CommonAdapter extends ArrayAdapter<CommonData> {

 
CommonFragment lfg;

 
public CommonAdapter(Context context, int resource, CommonFragment fg) {
 
super(context, resource);

 lfg
= fg;
 
}

 
//hover image
 
private BlurLayout mSampleLayout, mSampleLayout2, mSampleLayout3, mSampleLayout4;

 
@Override
 
public View getView(int position, View convertView, ViewGroup parent) {
 
ViewHolder holder;

 
if( convertView == null ) {
 holder
= new ViewHolder();
 convertView
= LayoutInflater.from( getContext() ).inflate( R.layout.activity_trending_adapter, parent, false );
 holder
.image = (ImageView) convertView.findViewById( R.id.image );
 holder
.caption=(TextView) convertView.findViewById(R.id.textView);
 
 convertView
.setTag(holder);

 

 
} else {
 holder
= (ViewHolder) convertView.getTag();
 
}


 
final ViewHolder tmp = holder;


 
Picasso.with(getContext()).load(getItem(position).getBgImage())
 
.placeholder(getContext().getResources().getDrawable(R.drawable.place)).
 error
(getContext().getResources().getDrawable(R.drawable.place)).
 
into(holder.image);


 
return convertView;
 
}

 
private class ViewHolder {
 
ImageView image;
 
ProgressBar progress;
 
TextView caption;
 

 
}
}


activity_trending_adapter:-

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 
xmlns:ads="http://schemas.android.com/apk/res-auto"
 
android:orientation="vertical"
 
android:layout_width="match_parent"
 
android:layout_height="match_parent">



 
<ImageView
 
android:id="@+id/image"

 
android:layout_width="match_parent"
 
android:layout_height="match_parent"
 
android:adjustViewBounds="true"

 
android:layout_below="@+id/textView"

 
android:layout_alignParentLeft="true"
 
android:layout_alignParentStart="true">

 
</ImageView>


</RelativeLayout>

Here also ad is not displaying with same logcat logs. I am still suspecting the layout file.

Priyanka Roy.


...

Priyanka Roy

unread,
Dec 9, 2015, 5:33:47 PM12/9/15
to Google Mobile Ads SDK Developers


On Thursday, December 10, 2015 at 3:59:16 AM UTC+5:30, Priyanka Roy wrote:
Hi Veer,

Here also ad is not displaying with same error in the logcat. 
 
 

Veer Arjun Busani

unread,
Dec 10, 2015, 10:15:42 AM12/10/15
to Google Mobile Ads SDK Developers
Hi Priyanka,

Can you send us a minimal archive of your project and let us know where all you want the AdView to be placed. We would gladly assist you with that. It looks like you have an AdView placed in the acitvity_trending_fragment and may I suggest you to change layout_width to wrap_content or ensure that the Fragment has sufficient width for the AdView. It could be the case where the AdView is being show due to insufficient banner size

Thanks,
Veer Arjun Busani
Mobile Ads SDK Team


Reply all
Reply to author
Forward
0 new messages