![](/img/trans.png)
[英]Activity starting another activity. Guarantee that the first activity's onPause will be called before second's onResume
[英]first activity's onPause not called when start two activity continuously and the second activity with translucent theme
就像標題所描述的那樣,當我連續開始兩個活動時,第二個活動有一個windowIsTranslucent
為真的主題。我發現沒有調用第一個活動的onPause
,這意味着所有這些活動都處於恢復狀態。
這個問題恰好發生在android pie(API 28)或更高版本上
startActivity(new Intent(this, Activity1.class));
startActivity(new Intent(this, Activity2.class));
<resources>
<!-- Base application theme. -->
<style name="AppThemeA" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
</resources>
<application
android:name="com.taou.maimai.MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppThemeA">
<activity android:name=".MainActivity"
android:launchMode="singleTask"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.taou.maimai.Activity1" />
<activity android:name="com.taou.maimai.Activity2"
/>
</application>
嘗試在onCreate
設置主題,如下所示:
public void onCreate(..){
super.onCreate();
setTheme(R.style.transcluent_theme);
setContentView(R.layout.main_activity_2);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.