当有人点击广告后回来的Android应用程序无法恢复 [英] Android app does not resume when someone comes back after clicking ad
本文介绍了当有人点击广告后回来的Android应用程序无法恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当有人点击广告,回来到应用程序的应用程序不会恢复。
我已经加入安卓launchMode =singleInstance
在mainfest和安卓:在活动alwaysRetainTaskState =真正的
声明清单。
我没有得到我要去哪里错了。
我的$ C $下.java文件如下:
公共类MainActivity扩展活动实现AdListener {
公共静态诠释计数= 0,dispad = 0;
公共静态的LinearLayout lay1;
私有静态final类<> []号码= {First.class};
保护AD浏览报AD浏览报;
查看admobAds;
@覆盖
保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main);
AD浏览报=(AD浏览报)findViewById(R.id.ad);
吐司面包= Toast.makeText(getApplicationContext(),点击广告
让它消失+
,Toast.LENGTH_LONG);
toast.show();
adView.loadAd(新AdRequest());
lay1 =(的LinearLayout)this.findViewById(R.id.mainlay);
admobAds =(查看)findViewById(R.id.ad);
//更多code
公共无效onDismissScreen(广告为arg0){
lay1.removeView(admobAds);
dispad = 1;
// TODO自动生成方法存根
}
}
解决方案
ü应该经历这个..... http://developer.android.com/reference/android/app/Activity.html
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
}
}
解决方案
u should go through this..... http://developer.android.com/reference/android/app/Activity.html
这篇关于当有人点击广告后回来的Android应用程序无法恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文