我的应用程序中有一个浮动按钮的服务(如 facebook messenger),当单击时,我的活动从后台返回,但它不会以与缩小时相同的方式返回,它会重新调用一次 onCreate更多,知道是什么导致了这种行为吗?
在我的清单中,活动与财产有关:
android:launchMode="singleTask"
它由我的服务调用,如下所示:
Intent i = new Intent(FloatingViewService.this, DrawerActivity2.class);
i.putExtra("fromController",true);
i.setFlags(FLAG_FROM_BACKGROUND);
FloatingViewService.this.startActivity(i);
我的主要问题是在活动内部,我有一个 webview,每次单击按钮并调用活动时它都会重新加载,而不是保持不变。
更新后这是我在清单中的活动
<activity
android:name=".DrawerActivity2"
android:configChanges="orientation"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/OtherTheme"/>
更新 2
值得一提的是,它是一个位于应用程序中的库。
我尝试使用此代码打开活动:
Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName()); startActivity(intent);
它打开了第一个(原始应用程序的)活动,而不是打开的活动。
任何帮助将不胜感激