简体   繁体   English

第一个活动的onPause在连续启动两个活动时未调用,而第二个活动具有半透明主题

[英]first activity's onPause not called when start two activity continuously and the second activity with translucent theme

Just as the title described, when I start two activity continuously, and the second activity has a theme that windowIsTranslucent is true。 I found that the first activity's onPause was not called, it means that all of this activities were under resumed status. 就像标题所描述的那样,当我连续开始两个活动时,第二个活动有一个windowIsTranslucent为真的主题。我发现没有调用第一个活动的onPause ,这意味着所有这些活动都处于恢复状态。
this problem just happen on android pie(API 28) or higher 这个问题恰好发生在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>

Try to set the theme in onCreate like this: 尝试在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.

相关问题 活动开始另一个活动。 确保第一个活动的onPause将在第二个活动的onResume之前调用 - Activity starting another activity. Guarantee that the first activity's onPause will be called before second's onResume 当活动为onPause()时启动一个timerTask - start a timerTask when activity is onPause() 在片段之间切换时会调用Activity onpause吗 - Will Activity onpause be called when switching between fragments Android 活动生命周期 - 何时调用“onPause”? - Android Activity LifeCycle - when 'onPause' is called? onPause 是否保证在 Activity 不再运行时调用? - Is onPause guaranteed to be called when an Activity is no longer running? 在Activity上调用onPause时,数据会发生什么 - What happens to data when onPause is called on Activity 当打开dialogFragment并调用onPause()时,活动崩溃 - Activity crashes when dialogFragment is opened and onPause() is called 在模拟器中重新启动活动时未调用OnPause() - OnPause() not called when relaunch activity in emulator 完成第一个活动后开始第二个活动 - Start second activity after finish the first activity 开始第二项活动,但失败回到第一项活动 - start second activity and fail to back to first activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM