在部分手机上,我的Activity被启动了两次。
但是这个Activity我设置了这些属性
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
试问你确定是被启动了两次?你是初始化创建视图还是,resume创建视图等等。关于activity实例类型的也是有类型设置的。
AndroidManifest.xml中的application标签下面的第一个activity是SplashActivity,第二个是MainActivity。
其中SplashActivity就是开屏也之后展示广告的。
下面的日志是我整理出来的
info, 01-30 17:36:54.317, 27560, 27560, AD_DEMO, MainActivity-------------onPause
info, 01-30 17:36:56.760, 27560, 27560, AD_DEMO, SplashActivity-------------onCreate
info, 01-30 17:36:56.790, 27560, 27560, AD_DEMO, SplashActivity-------------onResume------false
info, 01-30 17:36:57.277, 27560, 30045, AD_DEMO, SplashActivity-------------showSplahAd
info, 01-30 17:36:57.278, 27560, 30045, AD_DEMO, SplashActivity-------------fetchSplashAD
info, 01-30 17:36:57.729, 27560, 27560, AD_DEMO, SplashActivity-------------SplashADPresent
info, 01-30 17:36:57.755, 27560, 27560, AD_DEMO, SplashADTick 4974ms
info, 01-30 17:37:02.770, 27560, 27560, AD_DEMO, SplashADExposure
info, 01-30 17:37:02.770, 27560, 27560, AD_DEMO, SplashActivity-------------SplashADDismissed
info, 01-30 17:37:02.802, 27560, 27560, AD_DEMO, SplashActivity-------------onPause------true
info, 01-30 17:37:02.837, 27560, 27560, AD_DEMO, MainActivity-------------onResume
info, 01-30 17:37:03.070, 27560, 27560, AD_DEMO, SplashActivity-------------onDestroy
info, 01-30 17:37:03.295, 27560, 27560, AD_DEMO, MainActivity-------------onPause
info, 01-30 17:37:03.331, 27560, 27560, AD_DEMO, SplashActivity-------------onCreate
info, 01-30 17:37:03.347, 27560, 27560, AD_DEMO, SplashActivity-------------onResume------false
info, 01-30 17:37:03.843, 27560, 30404, AD_DEMO, SplashActivity-------------showSplahAd
info, 01-30 17:37:03.846, 27560, 30404, AD_DEMO, SplashActivity-------------fetchSplashAD
info, 01-30 17:37:04.174, 27560, 27560, AD_DEMO, SplashActivity-------------SplashADPresent
info, 01-30 17:37:04.238, 27560, 27560, AD_DEMO, SplashADTick 4936ms
info, 01-30 17:37:09.255, 27560, 27560, AD_DEMO, SplashADExposure
info, 01-30 17:37:09.255, 27560, 27560, AD_DEMO, SplashActivity-------------SplashADDismissed
info, 01-30 17:37:09.270, 27560, 27560, AD_DEMO, SplashActivity-------------onPause------true
info, 01-30 17:37:09.321, 27560, 27560, AD_DEMO, MainActivity-------------onResume
info, 01-30 17:37:09.555, 27560, 27560, AD_DEMO, SplashActivity-------------onDestroy
加了,但是没有效果。我感觉我的问题是app点击两次返回按钮退出app之后,app实际上没有结束进程,然后再次点击图标启动的时候连后台的进程也唤醒了,然后就启动两次了