Activity did not call finish? (API 23)

后端 未结 8 1684
渐次进展
渐次进展 2020-12-08 06:47

I am getting the following error and i have no clue as to why its happening.

Error:

08-23 17:07:46.533  22454-22454/com.a.b.c E/Andr         


        
相关标签:
8条回答
  • 2020-12-08 07:27

    This is a bug in Android M developer preview. More details

    0 讨论(0)
  • 2020-12-08 07:28

    where android 23> https://www.youtube.com/watch?v=NAcUGwCkrcs

    Manifest:

    android:theme="@android:style/Theme.Translucent.NoTitleBar"
    Activity extends from Activity. Not AppCompatActivity.
    

    and for version >= 23

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){     
        getWindow().setStatusBarColor(getResources().getColor(android.R.color.transparent))}
    
    0 讨论(0)
  • 2020-12-08 07:36

    I found a workaround. Call setVisible(true) in onStart():

    @Override
    protected void onStart() {
        super.onStart();
        setVisible(true);
    }
    
    0 讨论(0)
  • 2020-12-08 07:36

    It is due to setting a theme on an Activity that the user cannot see. I guess the reason Android does this is so you can't just run an invisible Activity indefinitely.

    Calling finish() in your activity before onResume() gets called (like the error message says) will stop this from happening.

    My use case was launching an invisible Activity to handle deep links and direct it to the correct part of my app.

    0 讨论(0)
  • 2020-12-08 07:36

    Try changing targetSdkVersion to 22 in build.gradle. Theme.NoDisplay shows error in api level 23.

    0 讨论(0)
  • 2020-12-08 07:39

    My invisible Activity shows a confirmation dialog. This did lose the material design look when I used android:Theme.Translucent.NoTitleBar.

    So, based on answers above and CommonWare's blog and the Android themes definitions I use this style, which extends a normal AppCompat.Light theme:

    <style name="AppTheme.NoDisplay" parent="Theme.AppCompat.Light">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowAnimationStyle">@android:style/Animation</item>
        <item name="android:windowDisablePreview">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>
    
    0 讨论(0)
提交回复
热议问题