title: Problem with admob
body: <p>OK, I had asked a similar <a href="https://stackoverflow.com/questions/5408336/a-common-footer-for-an-entire-application-android">question</a> before and had got an answer but that was too general a question. </p>
  
  <p>Now I've an app in which there are plenty of activities. Each activity has the same admob (AdView) layout being included in its layout file. Now the problem is when I go from one activity to the other after the first screen has finished loading the ad, the second activity still waits for another ad fetch cycle to happen [ie., it again sends an ad request and displays a new ad]. All I want to do is for my app to show the same instance of the ad in every activity. [Same instance meaning: I have a time interval based on which the ads must refresh, so a new ad request must be sent only when the time limit expires, not when user navigates from one activity to another.]</p>
  
  <p>Is there anyway I can do this. I have tried the "Singleton" approach mentioned in the earlier solution but there are lot of complications cos everytime I do that, it says that the specified child already has a parent and a call to removeView on the parent is necessary. </p>
  
  <p>Am I doing anything wrong (OR/AND) can anybody help me with some other solution??</p>
  
  <p>My Singleton class is here:</p>
  
  <pre><code>public class CommonAdFooter {
  static final CommonAdFooter commonAdFooter = new CommonAdFooter();
  static AdView admobView;
  LayoutInflater LInflater;
  
  private CommonAdFooter() {
      LInflater = (LayoutInflater) Constants.context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
      admobView = (AdView) LInflater.inflate(R.layout.ad_layout, null);
      LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT,
              LayoutParams.WRAP_CONTENT);
      lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      admobView.setLayoutParams(lp);
  }
  
  public static AdView getAdLayout() {
      return admobView;
  }
  }
  </code></pre>
  
  <p>and this is my layout file for the ads</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;com.admob.android.ads.AdView
  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:myapp="..."
  android:id="@+id/ad" android:layout_alignParentBottom="true"
  android:background="#C9E3F6" android:layout_width="fill_parent"
  android:layout_height="wrap_content" myapp:backgroundColor="#006699"
  myapp:primaryTextColor="#C9E3F6" myapp:secondaryTextColor="#C9E3F6" /&gt;
  </code></pre>
  
  <p>Edit: Admob <a href="http://developer.admob.com/wiki/API" rel="nofollow noreferrer">API</a> link added.</p>