问题
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