Android app does not resume when someone comes back after clicking ad

橙三吉。 提交于 2019-12-12 03:54:12

问题


When someone clicks on the ad and comes back to the app the app is not resuming. I have added android:launchMode="singleInstance" in the mainfest and android:alwaysRetainTaskState="true" in the activity declaration in manifest.

I am not getting where am i going wrong.

My code for .java file is as follows :

 public class MainActivity extends Activity implements AdListener{

 public static int count=0,dispad=0;
 public static LinearLayout lay1;
 private static final Class<?>[] NUMBERS = {First.class};
  protected AdView adView;
    View admobAds;


   @Override
    protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adView = (AdView)findViewById(R.id.ad);

Toast toast = Toast.makeText(getApplicationContext(), "Click on the ad to      
       make        it     disappear" +
            "", Toast.LENGTH_LONG);
    toast.show();

 adView.loadAd(new AdRequest());

 lay1=(LinearLayout)this.findViewById(R.id.mainlay);

 admobAds = (View) findViewById(R.id.ad);

   //More code 

    public void onDismissScreen(Ad arg0) {

    lay1.removeView(admobAds);
    dispad=1;
    // TODO Auto-generated method stub

}
   }

回答1:


u should go through this..... http://developer.android.com/reference/android/app/Activity.html




回答2:


There was a problem with android:alwaysRetainTaskState="true" as i was not including it in every activity.

when i added this code in the activity my app is now not restarting but the ads are still shown up.



来源:https://stackoverflow.com/questions/15674643/admob-adlistner-not-working-properly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!