问题:
My Launching Activity creatively named LoadingActivity
's onCreate method is called 2 times.
清单内容:
<manifest>
<application>
...
<activity
android:launchMode="singleTop"
android:name="com.awesome.app.activites.LoadingActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>
</manifest>
First onCreate call is called with Bundle savedInstanceState
which is null
, shortly after which the onCreate method is called again, but this time with Bundle savedInstanceState which contains the following serialized content:
Bundle[{com.google.app_measurement.screen_service=Bundle[{referrer_name=LoadingActivity, id=1612091517631091562, name=null}], android:viewHierarchyState=Bundle[{android:views={16908290=android.view.AbsSavedState$1@a24446f, 2131296302=android.view.AbsSavedState$1@a24446f, 2131296313=android.view.AbsSavedState$1@a24446f, 2131296424=android.view.AbsSavedState$1@a24446f, 2131296445=android.widget.ProgressBar$SavedState@b25257c, 2131296581=android.view.AbsSavedState$1@a24446f, 2131296582=android.view.AbsSavedState$1@a24446f}}], androidx.lifecycle.BundlableSavedStateRegistry.key=Bundle[{}], android:lastAutofillId=1073741823, android:fragments=android.app.FragmentManagerState@a24ee05}]
是的,这并不意味着什么,但这可能与帖子底部的内容有关。
尝试过:
I have tried setting launchmode settings with android:launchMode="singleTop"
for the LoadingActivty
in my AndroidManifest.xml
, but this does not help at all, it still runs the onCreate 2 times.
我已经遍历了onCreate方法,没有再在哪里onCreate或更改ApplicationContext设置,即方向(以物理方式或程序方式)等。
任何想法为什么会发生这种情况以及我可以采取什么措施来解决。
为了它的价值,我最近更新了我的部门并在清单中看到了这一点:
它使用纵向启动模式进行编译(出于过时的原因更改软件包名称),但是我认为这可能与两次启动有关