PSA: Android 6.0 Theme.NoDisplay Regression



id="hist_frame" name="hist_frame2076234133" class="ss" tabindex="-1" style="height: 30px; left: -100px; position: absolute; top: -100px; width: 30px; font-family: Roboto, arial, sans-serif; font-size: 13px;">
与合适的人分享合适的内容。
首页
个人资料
人脉
收藏集
热门
社群
活动
环聊
信息页
设置
反馈
帮助  ·   地区
隐私权  ·   条款  ·   地图条款
29,255 位关注者 | 3,284,128 次查看

Dianne Hackborn

公开分享  -  2015年11月5日
 
PSA: The new requirement to immediately finish an activity if using Theme.NoDisplay is not a regression, this has always been a requirement of it (see  https://developer.android.com/reference/android/R.style.html#Theme_NoDisplay for example).

The reason the platform in M is now crashing the app if it doesn't use this is because not using it would previously break in very subtle and mysterious ways.  For example, you would sometimes end up with your app ANRing for no reason.

Why is this?  Because what Theme.NoDisplay actually does is completely prevent the window for the activity from being shown.  That is, the activity gets launched, but a window for it is never displayed.

If you don't immediately finish the activity in this situation, the app is in a bad state: it has an activity being launched that the system is waiting for a window to be displayed for, but no window will ever appear.  So depending on how the timing goes, you can end up with the system sitting there waiting to see the window appear, which it never does, and bam you have ANRed.

We realized we were repeatedly debugging reports from developers of their apps ANRing when they shouldn't be, tracking those problems down to misuse of Theme.NoDisplay causing their random ANRs.  It is better for all of us if the platform catches this consistently, early, with a clear message about what the app did wrong.

If you really need to have a transparent activity that doesn't immediately finish, you can use Theme.Translucent.NoTitleBar to have a window that is completely transparent.
翻译
154
40
Ankur Nigam的个人资料照片 陈剑锋(chenupt)的个人资料照片 Jomar Tigcal的个人资料照片 Chris Boyle的个人资料照片
8 条评论
翻译
Chris P
2015年11月5日
+
5
6
5
 
Public Service Annoucement
翻译
翻译
Said Tahsin Dane
2015年11月5日
+
1
2
1
 
I just created a library today which creates an Activity with no UI just to request a permission. I first wondered that why my sample application does not crash. Then, I realized that I actually used Theme.Translucent.NoTitleBar. 
翻译
翻译
翻译
Liran Barsisa
2015年11月9日
 
I've never used this theme. What can be its purpose? Can you give an example? 
Would this be a good example: opening an activity just to show a dialog ?
翻译
翻译
发表评论…

id="hist_frame" name="hist_frame2076234133" class="ss" tabindex="-1" style="height: 30px; left: -100px; position: absolute; top: -100px; width: 30px; font-family: Roboto, arial, sans-serif; font-size: 13px;">
与合适的人分享合适的内容。
首页
个人资料
人脉
收藏集
热门
社群
活动
环聊
信息页
设置
反馈
帮助  ·   地区
隐私权  ·   条款  ·   地图条款
29,255 位关注者 | 3,284,128 次查看

Dianne Hackborn

公开分享  -  2015年11月5日
 
PSA: The new requirement to immediately finish an activity if using Theme.NoDisplay is not a regression, this has always been a requirement of it (see  https://developer.android.com/reference/android/R.style.html#Theme_NoDisplay for example).

The reason the platform in M is now crashing the app if it doesn't use this is because not using it would previously break in very subtle and mysterious ways.  For example, you would sometimes end up with your app ANRing for no reason.

Why is this?  Because what Theme.NoDisplay actually does is completely prevent the window for the activity from being shown.  That is, the activity gets launched, but a window for it is never displayed.

If you don't immediately finish the activity in this situation, the app is in a bad state: it has an activity being launched that the system is waiting for a window to be displayed for, but no window will ever appear.  So depending on how the timing goes, you can end up with the system sitting there waiting to see the window appear, which it never does, and bam you have ANRed.

We realized we were repeatedly debugging reports from developers of their apps ANRing when they shouldn't be, tracking those problems down to misuse of Theme.NoDisplay causing their random ANRs.  It is better for all of us if the platform catches this consistently, early, with a clear message about what the app did wrong.

If you really need to have a transparent activity that doesn't immediately finish, you can use Theme.Translucent.NoTitleBar to have a window that is completely transparent.
翻译
154
40
Ankur Nigam的个人资料照片 陈剑锋(chenupt)的个人资料照片 Jomar Tigcal的个人资料照片 Chris Boyle的个人资料照片
8 条评论
Shuhrat Dehkanov
2015年11月5日
 
Sorry, but what does PSA stand for? 
翻译
Chris P
2015年11月5日
+
5
6
5
 
Public Service Annoucement
翻译
David Gerber
2015年11月5日
 
The real problems: 1) lack of documentation 2) no useful response on b.android.com
翻译
Said Tahsin Dane
2015年11月5日
+
1
2
1
 
I just created a library today which creates an Activity with no UI just to request a permission. I first wondered that why my sample application does not crash. Then, I realized that I actually used Theme.Translucent.NoTitleBar. 
翻译
Marius Gedminas
2015年11月7日
 
And what does ANR stand for?
翻译
Dianne Hackborn
2015年11月8日
+
1
2
1
 
+Marius Gedminas Application Not Responding
翻译
Liran Barsisa
2015年11月9日
 
I've never used this theme. What can be its purpose? Can you give an example? 
Would this be a good example: opening an activity just to show a dialog ?
翻译
meng wang
2015年11月11日
 
top
翻译
发表评论…

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个错误通常表示您的Java项目中缺少Apache Commons Math库的依赖。您可以通过在项目的pom.xml文件中添加以下依赖项来解决此问题: ``` <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-math3</artifactId> <version>3.6.1</version> </dependency> ``` 如果您不使用Maven,则需要手动下载并将commons-math3.jar文件添加到您的项目中。 ### 回答2: Java中的错误信息"程序包org.apache.commons.math3.stat.regression不存在"表示在程序中尝试使用org.apache.commons.math3.stat.regression包,但该包不存在或无法找到。 要解决此问题,可以尝试以下几种方法: 1. 重新导入依赖:首先确保在项目的构建工具(如Maven或Gradle)的配置文件中,org.apache.commons.math3.stat.regression依赖项的正确版本已添加。然后,重新构建项目以确保依赖项成功导入。 2. 检查包名:确认在代码中正确地引用了org.apache.commons.math3.stat.regression包。包名大小写敏感,碰到拼写错误可能导致无法找到包。请检查您的代码中所有使用该包的地方,包括导入语句和类的使用。 3. 检查项目设置:确保已经正确配置了Java构建路径以包括相关的.jar文件或模块。检查项目的构建路径设置,确认正确地包含了所需的库文件。 4. 更新或替换库文件:如果org.apache.commons.math3.stat.regression包是外部库中的一部分,尝试更新或替换库文件以确保您使用了正确版本的库。您可以访问官方网站或版本控制库来获取正确的库文件版本。 5. 检查运行环境:确认您的Java运行环境具有足够的权限和配置以访问并使用org.apache.commons.math3.stat.regression包。某些情况下,特定的安全策略或权限限制可能会阻止对特定包的访问。 总之,解决"程序包org.apache.commons.math3.stat.regression不存在"错误的方法包括重新导入依赖、检查包名和项目设置、更新或替换库文件,以及检查运行环境的配置。 ### 回答3: java: 程序包org.apache.commons.math3.stat.regression不存在是报错信息,表示在Java代码中引入的org.apache.commons.math3.stat.regression包不存在。 要解决这个问题,可以按照以下步骤进行: 1. 首先,确认是否正确引入了org.apache.commons.math3.stat.regression包。检查代码中的导入语句是否正确,并确保该包中包含了所需的类。 2. 确保已正确配置项目的依赖项或构建脚本。如果项目使用Maven或Gradle等构建工具进行管理,确保已正确添加了对org.apache.commons.math3.stat.regression包的依赖。 3. 检查所使用的Java版本是否与所需的包版本兼容。有些包需要特定的Java版本才能正常使用。如果版本不兼容,可以尝试升级或降级Java版本,或者寻找与所使用Java版本兼容的包版本。 4. 如果以上步骤都无效,可能需要重新下载或更新org.apache.commons.math3.stat.regression包。可以访问官方网站或其他Java开发者社区,搜索并下载最新的版本。 总之,解决这个问题的关键是确定是否正确引入了org.apache.commons.math3.stat.regression包,并确保项目的依赖项和Java版本是正确的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值