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;">
加入 Google+
与合适的人分享合适的内容。

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.
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.
Mark Murphy's CommonsBlog
154
40




8 条评论

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
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 ?
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;">
翻译
加入 Google+
与合适的人分享合适的内容。

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.
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.
Mark Murphy's CommonsBlog
154
40




8 条评论

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
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 ?
Would this be a good example: opening an activity just to show a dialog ?
翻译
发表评论…