I have successfully integrated admob in my android application. But i am getting lower epcm and higher impression. As a result i am not getting much paid. My add is loading whenever a new activity is started. I have added
new FloatingAd(InboxListActivity.this);
Here is the floatingad class:
public FloatingAd(Context mContext){
Context context = mContext;
// Locate the Banner Ad in activity_main.xml
AdView adView = (AdView) ((Activity) context).findViewById(R.id.adView);
// Request for Ads
AdRequest adRequest = new AdRequest.Builder()
.build();
adView.loadAd(adRequest);
}
and here is my xml code:
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad" />
on every onCreateView(). So it is creating a new instance whenever there is a new activity. Now i am trying to make the addview constant for all screen. so that it may not create a new instance of the add on starting a new activity. How to achieve that ? Please note that my app is activity based not fragment based.
You cannot shared an AdView across Activities.
You either refactor your app so that you use Fragments with the AdView being shown regardless of which Fragment is visible or you live with low eCPM because you are creating new AdViews as you start each new Activity.
NB It is typical to have a single main Activity that your users spend most of their time in as the one in which ads are shown.