【Android】An activity without a UI must call finish() before onResume() complete
来源:互联网 发布:mac磁盘被锁定 编辑:程序博客网 时间:2024/05/04 04:31
今天遇到这样的一个bug,我的测试机是Android 7.0,经过追踪得到一下关键出错信息:
An activity without a UI must call finish() before onResume() completes
很明显这是因为当前的activity没有UI造成的,通过查看源码发现这个问题在6.0之前不存在,在6.0之后google对着快做了强制要求,下面是
Android 6.0相应的源码:
final void performResume() { performRestart(); mFragments.execPendingActions(); mLastNonConfigurationInstances = null; mCalled = false; // mResumed is set by the instrumentation mInstrumentation.callActivityOnResume(this); if (!mCalled) { throw new SuperNotCalledException( "Activity " + mComponent.toShortString() + " did not call through to super.onResume()"); } // invisible activities must be finished before onResume() completes if (!mVisibleFromClient && !mFinished) { Log.w(TAG, "An activity without a UI must call finish() before onResume() completes"); if (getApplicationInfo().targetSdkVersion > android.os.Build.VERSION_CODES.LOLLIPOP_MR1) { throw new IllegalStateException( "Activity " + mComponent.toShortString() + " did not call finish() prior to onResume() completing"); } } // Now really resume, and install the current status bar and menu. mCalled = false; mFragments.dispatchResume(); mFragments.execPendingActions(); onPostResume(); if (!mCalled) { throw new SuperNotCalledException( "Activity " + mComponent.toShortString() + " did not call through to super.onPostResume()"); }}
16行就是打出的出错日志
知道为什么出错后解决这个问题就不难了,既然我的activity是没有UI的,出错的activity主题的配置如下:
<activity android:name=".DialogActivity" ... android:theme="@android:style/Theme.NoDisplay/>
这个一个没有UI的主题,为了解决问题,只需要将主题改成透明的即可,ps:记住透明不等于没有UI哦,如下所示:
<activity android:name=".DialogActivity" ... android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
0 0
- 【Android】An activity without a UI must call finish() before onResume() complete
- Activity did not call finish() prior to onResume() completing原因和解决办法
- android 6.0+ java.lang.IllegalStateException did not call finish() prior to onResume() completing
- 安卓6.0以上机型微信登录时提示Activity did not call finish() prior to onResume() completing
- How Many Roads Must A Man Walk Down Before you call him a man?
- A - Before an Exam
- Android Activity Lifecycle(Finish)
- 微信支付问题:WeChatNotifyActivity} did not call finish() prior to onResume() completing
- Crashlytics was applied to a project without an Android plugin.
- Android Activity finish() 流程走读
- android onResume is called before you unlock the phone
- android onResume is called before you unlock the phone
- Android - Activity的onStart()和onResume()
- android Activity的onPause()与onResume()
- Android onResume() 返回Activity时调用
- Complete和Finish
- Activity finish()
- activity finish
- Dubbo(三) 聚合工程之Service层接口Demo
- 【24.67%】【codeforces 551C】 GukiZ hates Boxes
- 图像处理之—振铃现象
- 洛谷最大子树和解题报告
- KISSY基础篇乄KISSY之DOM(2)
- 【Android】An activity without a UI must call finish() before onResume() complete
- 【Mysql】复杂SQL调优一例
- 记录caffe+ win7 64 +VS2013+matlab2016a+python 安装
- 大并发服务器开发之基于对像的编程风格
- 第十六周项目1-验证算法(1)冒泡排序
- 在线用户信息统计&单用户登录(update)
- ArcGIS API For Javacsript编辑客户端图形
- solr使用word分词时高亮结果错位的解决办法
- LocalBroadcastReceiver