J'utilise PublisherAdView
dans mon application pour l'intégration des annonces. J'ai 3 annonces par vue et c'est à l'intérieur ViewPager
. Les annonces sont visibles intially, mais après avoir visité certain nombre de fragments à l'intérieur ViewPager
, annonces cessent de fonctionner en donnant ce journal:DFP cesse d'afficher les annonces jusqu'à ce que l'application soit redémarrée
I/Ads: Ad is not visible. Not refreshing ad.
I/Ads: Scheduling ad refresh 60000 milliseconds from now.
pour tous, jusqu'à ce que l'application se redémarrée. J'ai également mis en œuvre les méthodes onPause()
, onResume()
et onDestroy()
pour tous les publsihersAdViews.
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context="com.expressdigital.express.fragments.NewsDetailFragment">
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/news_details_swipe_to_refresh">
<android.support.v4.widget.NestedScrollView
android:id="@+id/news_details_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="@android:color/transparent"
android:fillViewport="true"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants">
<RelativeLayout
android:id="@+id/news_details_relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants">
<!-- top ad layout-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/news_details_top_ad_view_layout"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="@+id/news_details_screen_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/news_details_top_ad_view_layout"
android:layout_marginTop="10dp"
android:lineSpacingMultiplier="1.2"
android:paddingLeft="@dimen/news_details_title_left_padding"
android:paddingRight="@dimen/news_details_title_right_padding"
android:textColor="@color/black"
android:textSize="@dimen/news_details_heading_text_size"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/author_name_and_time_passed_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/news_details_screen_title"
android:orientation="horizontal"
android:paddingBottom="@dimen/author_time_layout_vertical_padding"
android:paddingTop="@dimen/author_time_layout_vertical_padding">
<TextView
android:id="@+id/details_author_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/news_details_author_name_left_margin"
android:layout_marginRight="@dimen/news_details_author_name_right_margin"
android:textColor="@color/login_top"
android:textSize="@dimen/news_details_author_name_text_size" />
<com.expressdigital.express.utils.CircleImageView
android:layout_width="8dp"
android:layout_height="8dp"
android:layout_gravity="center_vertical"
android:src="@color/divider_bottom" />
<TextView
android:id="@+id/details_publish_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/news_details_time_horizontal_margin"
android:layout_marginRight="@dimen/news_details_time_horizontal_margin"
android:textAllCaps="true"
android:textColor="@color/login_top"
android:textSize="@dimen/news_details_time_text_size" />
</LinearLayout>
<ImageView
android:id="@+id/news_description_top_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/author_name_and_time_passed_layout"
android:adjustViewBounds="true"
android:scaleType="centerCrop" />
<WebView
android:id="@+id/news_description_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/news_description_top_image"
android:layout_marginLeft="@dimen/news_details_content_horizontal_padding"
android:layout_marginRight="@dimen/news_details_content_horizontal_padding"
android:layout_marginTop="@dimen/news_details_content_vertical_padding" />
<View
android:layout_width="match_parent"
android:layout_height="0.8dp"
android:layout_below="@id/news_description_detail"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:id="@+id/view_above_mrec_ad"
android:background="@color/divider_bottom"
/>
<!-- bottom ad layout-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/news_details_bottom_ad_view_layout"
android:layout_centerHorizontal="true"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_below="@id/view_above_mrec_ad"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_below="@id/news_details_bottom_ad_view_layout"
android:id="@+id/extraSection">
<View
android:layout_width="match_parent"
android:layout_height="0.8dp"
android:layout_below="@id/news_description_detail"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:id="@+id/view_above_comments_layout"
android:background="@color/divider_bottom"
/>
<LinearLayout
android:id="@+id/details_comments_buttons_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/comment_buttons_layout_bottom_margin"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="@+id/details_add_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/news_details_add_comment_horizontal_padding"
android:layout_marginRight="@dimen/news_details_add_comment_horizontal_padding"
android:layout_weight="1"
android:paddingTop="@dimen/comments_buttons_vertical_padding"
android:paddingBottom="@dimen/comments_buttons_vertical_padding"
android:paddingLeft="@dimen/comments_buttons_horizontal_padding"
android:paddingRight="@dimen/comments_buttons_horizontal_padding"
android:gravity="center"
android:textAllCaps="true"
android:textSize="@dimen/news_details_comments_button_text_size"
android:background="@drawable/add_comment_button_background"
android:text="@string/add_comment"
android:textColor="@color/read_all" />
<TextView
android:id="@+id/details_read_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/news_details_comment_horizontal_padding"
android:layout_marginRight="@dimen/news_details_comment_horizontal_padding"
android:layout_weight="1"
android:paddingTop="@dimen/comments_buttons_vertical_padding"
android:paddingBottom="@dimen/comments_buttons_vertical_padding"
android:paddingLeft="@dimen/comments_buttons_horizontal_padding"
android:paddingRight="@dimen/comments_buttons_horizontal_padding"
android:gravity="center"
android:textAllCaps="true"
android:textSize="@dimen/news_details_comments_button_text_size"
android:text="@string/read_comments"
android:background="@drawable/read_comments_background"
android:textColor="@color/white" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.8dp"
android:layout_below="@id/details_comments_buttons_layout"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@color/divider_bottom"
android:id="@+id/view_below_comments_layout"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/details_next_story_layout"
android:layout_below="@id/view_below_comments_layout"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="@+id/details_next_story_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/details_comments_buttons_layout"
android:paddingLeft="@dimen/news_details_recommend_text_horizontal_padding"
android:paddingRight="@dimen/news_details_recommend_text_horizontal_padding"
android:text="@string/next_story"
android:textColor="@color/we_recommend"
android:textSize="@dimen/we_recommend_text_size"
android:textAllCaps="true"
android:textStyle="bold"
android:paddingBottom="10dp" />
<TextView
android:id="@+id/details_next_story_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/details_comments_buttons_layout"
android:paddingLeft="@dimen/news_details_recommend_text_horizontal_padding"
android:paddingRight="@dimen/news_details_recommend_text_horizontal_left_padding"
android:text="@string/next_story"
android:textSize="@dimen/story_heading_text_size"
android:paddingBottom="10dp" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/next_story_icon"
android:layout_weight="8"
android:layout_gravity="center_vertical"
android:padding="10dp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.8dp"
android:layout_below="@id/details_next_story_layout"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@color/divider_bottom"
android:id="@+id/view_below_next_story"
/>
<View
android:id="@+id/view_for_detail_news_lazy_loading"
android:layout_width="match_parent"
android:layout_height="@dimen/news_details_blank_views_below_comment_layout_height"
android:layout_below="@id/news_description_detail"
android:layout_marginTop="@dimen/news_details_blank_views_below_comment_layout_top_margin"
android:visibility="gone"
android:background="@android:color/transparent" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/news_details_bottom_progress_layout_width"
android:layout_height="@dimen/news_details_bottom_progress_layout_height"
android:layout_centerInParent="true"
android:gravity="center"
android:layout_below="@id/view_below_next_story"
android:id="@+id/detail_news_progress_bar"
>
<com.expressdigital.express.utils.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/express_loader"
android:alpha="0.7"
android:layout_marginRight="@dimen/news_details_bottom_logo_padding"
android:layout_marginLeft="@dimen/news_details_bottom_logo_padding"
android:layout_margin="@dimen/news_details_bottom_logo_padding"
android:layout_marginBottom="@dimen/news_details_bottom_logo_padding"
/>
<ProgressBar
android:indeterminate="true"
android:layout_width="@dimen/news_details_bottom_progress_layout_width"
android:layout_height="@dimen/news_details_bottom_progress_layout_height"
style="@style/CustomProgressBar"
/>
</RelativeLayout>
<TextView
android:id="@+id/details_we_recommend_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/view_for_detail_news_lazy_loading"
android:paddingLeft="@dimen/news_details_recommend_text_horizontal_padding"
android:paddingRight="@dimen/news_details_recommend_text_horizontal_padding"
android:text="@string/related_stories"
android:textColor="@color/we_recommend"
android:textSize="@dimen/we_recommend_text_size"
android:textAllCaps="true"
android:textStyle="bold"
android:visibility="gone" />
<android.support.v7.widget.RecyclerView
android:id="@+id/details_we_recommend_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/details_we_recommend_text"
android:foregroundGravity="center"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:visibility="gone" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.8dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_below="@id/extraSection"
android:background="@color/divider_bottom"
android:id="@+id/view_above_details_ad_view"
/>
<!-- ad type mrec layout-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/news_details_ad_view"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_centerHorizontal="true"
android:layout_below="@id/view_above_details_ad_view"
/>
<View
android:layout_width="match_parent"
android:layout_height="0.8dp"
android:layout_below="@id/news_details_ad_view"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@color/divider_bottom"
android:id="@+id/view_below_details_ad_view"
/>
</RelativeLayout>
</FrameLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/news_details_progress_layout"
android:layout_marginBottom="@dimen/actionbar_size">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="@dimen/actionbar_size">
<RelativeLayout
android:layout_width="@dimen/news_details_progress_layout_width"
android:layout_height="@dimen/news_details_progress_layout_height"
android:layout_centerInParent="true"
android:gravity="center"
>
<com.expressdigital.express.utils.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/express_loader"
android:alpha="0.7"
android:layout_marginRight="@dimen/news_details_logo_padding"
android:layout_marginLeft="@dimen/news_details_logo_padding"
android:layout_margin="@dimen/news_details_logo_padding"
android:layout_marginBottom="@dimen/news_details_logo_padding"
/>
<ProgressBar
android:layout_width="@dimen/news_details_progress_layout_width"
android:layout_height="@dimen/news_details_progress_layout_height"
style="@style/CustomProgressBar"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Possible son doublon http://stackoverflow.com/questions/23922978/ad-is-not-visible-not-refreshing-add-scheduling-ad-refresh-60000-miliseconds-f – Shailesh
@Shailesh dans ce fil d'annonces ne sont pas visibles tout le temps, mais ce n'est pas le cas les publicités sont visibles lorsque nous ouvrons l'application. –
Le problème est que vous essayez de charger l'annonce immédiate dans votre fragment lorsque vous balayez votre page d'affichage. Possible alors s'il vous plaît partager votre fichier xml où vous pouvez définir votre 'ad' – Shailesh