Skip to content

Commit c65e678

Browse files
committed
📄深入源码排查 FLAG_ACTIVITY_NEW_TASK 导致的 Activity 无法正常启动 IO-01/Blog@605f0c4
1 parent f9ab840 commit c65e678

File tree

15 files changed

+256
-98
lines changed

15 files changed

+256
-98
lines changed

index.html

+19-25
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<meta property="og:url" content="/">
2525
<meta property="og:description" content="Eureka is a elegant and powerful theme for Hugo.">
2626
<meta property="og:site_name" content="IO01 Blog">
27-
<meta property="og:updated_time" content="2021-06-18T00:00:00+00:00">
27+
<meta property="og:updated_time" content="2021-09-16T00:00:00+00:00">
2828
<meta property="article:section" content>
2929
<link rel=alternate type=application/rss+xml href=/index.xml title="IO01 Blog">
3030
<body class="flex flex-col min-h-screen">
@@ -68,6 +68,24 @@
6868
<div class="flex flex-col-reverse lg:flex-row justify-between">
6969
<div class=w-full>
7070
<div class=mb-4>
71+
<a href=/posts/%E6%B7%B1%E5%85%A5%E6%BA%90%E7%A0%81%E6%8E%92%E6%9F%A5-flag_activity_new_task-%E5%AF%BC%E8%87%B4%E7%9A%84-activity-%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%90%AF%E5%8A%A8/ class="font-bold text-xl hover:text-eureka">深入源码排查 FLAG_ACTIVITY_NEW_TASK 导致的 Activity 无法正常启动</a>
72+
</div>
73+
<div class=content>
74+
引言 众所周知 Android 中 Activity 有四种启动模式,决定了是否创建新的 Activity 实例或复用当前实例。但是实际上 Activity 的启动十分复杂,不单单是 android:launchMode 就能决定的,多个 Intent Flag 都能改变启动的行为
75+
</div>
76+
<div class="flex flex-wrap flex-row items-center mt-2 text-tertiary-text">
77+
<div class="mr-6 my-2">
78+
<i class="fas fa-calendar mr-1"></i>
79+
<span>2021-09-16</span>
80+
</div>
81+
</div>
82+
</div>
83+
</div>
84+
</div>
85+
<div class=py-6>
86+
<div class="flex flex-col-reverse lg:flex-row justify-between">
87+
<div class=w-full>
88+
<div class=mb-4>
7189
<a href=/posts/%E9%81%B5%E5%BE%AA-google-%E5%BA%94%E7%94%A8%E6%8C%87%E5%8D%97%E7%9A%84-retrofit-+-coroutine-%E5%B0%81%E8%A3%85/ class="font-bold text-xl hover:text-eureka">遵循 Google 应用指南的 Retrofit + Coroutine 封装</a>
7290
</div>
7391
<div class=content>
@@ -167,30 +185,6 @@
167185
</div>
168186
</div>
169187
</div>
170-
<div class=py-6>
171-
<div class="flex flex-col-reverse lg:flex-row justify-between">
172-
<div class=w-full>
173-
<div class=mb-4>
174-
<a href=/posts/%E4%BB%8E%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6%E8%B0%88%E8%B5%B7-arrays.aslist%E4%B8%89%E5%9D%91/ class="font-bold text-xl hover:text-eureka">从阿里规约谈起-Arrays.asList 三坑</a>
175-
</div>
176-
<div class=content>
177-
前言 将数组转换成 List 是日常开发十分常见的操作,对此 JDK 提供了一个非常好用的工具类:
178-
List list = Arrays.asList(array); 但是如果操纵 List 的内容的话,阿里规约会给出一个提示:
179-
于是深入看了下,发现 Arrays.asList 有三个日常开发中容易坑人的地方。
180-
</div>
181-
<div class="flex flex-wrap flex-row items-center mt-2 text-tertiary-text">
182-
<div class="mr-6 my-2">
183-
<i class="fas fa-calendar mr-1"></i>
184-
<span>2019-09-24</span>
185-
</div>
186-
<div class="mr-6 my-2">
187-
<i class="fas fa-th-list mr-1"></i>
188-
<a href=/series/%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6/ class=hover:text-eureka>阿里规约</a>
189-
</div>
190-
</div>
191-
</div>
192-
</div>
193-
</div>
194188
</div>
195189
</div>
196190
<ul class="pagination pagination-default">

index.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>IO01 Blog</title><link>/</link><description>Recent content on IO01 Blog</description><generator>Hugo -- gohugo.io</generator><copyright>&amp;copy; {year} &lt;a href="https://blog.io01.xyz/">IO01&lt;/a></copyright><lastBuildDate>Fri, 18 Jun 2021 00:00:00 +0000</lastBuildDate><atom:link href="/index.xml" rel="self" type="application/rss+xml"/><item><title>遵循 Google 应用指南的 Retrofit + Coroutine 封装</title><link>/posts/%E9%81%B5%E5%BE%AA-google-%E5%BA%94%E7%94%A8%E6%8C%87%E5%8D%97%E7%9A%84-retrofit-+-coroutine-%E5%B0%81%E8%A3%85/</link><pubDate>Fri, 18 Jun 2021 00:00:00 +0000</pubDate><guid>/posts/%E9%81%B5%E5%BE%AA-google-%E5%BA%94%E7%94%A8%E6%8C%87%E5%8D%97%E7%9A%84-retrofit-+-coroutine-%E5%B0%81%E8%A3%85/</guid><description>&lt;h2 id="前言">前言&lt;/h2>
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>IO01 Blog</title><link>/</link><description>Recent content on IO01 Blog</description><generator>Hugo -- gohugo.io</generator><copyright>&amp;copy; {year} &lt;a href="https://blog.io01.xyz/">IO01&lt;/a></copyright><lastBuildDate>Thu, 16 Sep 2021 00:00:00 +0000</lastBuildDate><atom:link href="/index.xml" rel="self" type="application/rss+xml"/><item><title>深入源码排查 FLAG_ACTIVITY_NEW_TASK 导致的 Activity 无法正常启动</title><link>/posts/%E6%B7%B1%E5%85%A5%E6%BA%90%E7%A0%81%E6%8E%92%E6%9F%A5-flag_activity_new_task-%E5%AF%BC%E8%87%B4%E7%9A%84-activity-%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%90%AF%E5%8A%A8/</link><pubDate>Thu, 16 Sep 2021 00:00:00 +0000</pubDate><guid>/posts/%E6%B7%B1%E5%85%A5%E6%BA%90%E7%A0%81%E6%8E%92%E6%9F%A5-flag_activity_new_task-%E5%AF%BC%E8%87%B4%E7%9A%84-activity-%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%90%AF%E5%8A%A8/</guid><description>引言 众所周知 Android 中 Activity 有四种启动模式,决定了是否创建新的 Activity 实例或复用当前实例。但是实际上 Activity 的启动十分复杂,不单单是 android:launchMode 就能决定的,多个 Intent Flag 都能改变启动的行为</description></item><item><title>遵循 Google 应用指南的 Retrofit + Coroutine 封装</title><link>/posts/%E9%81%B5%E5%BE%AA-google-%E5%BA%94%E7%94%A8%E6%8C%87%E5%8D%97%E7%9A%84-retrofit-+-coroutine-%E5%B0%81%E8%A3%85/</link><pubDate>Fri, 18 Jun 2021 00:00:00 +0000</pubDate><guid>/posts/%E9%81%B5%E5%BE%AA-google-%E5%BA%94%E7%94%A8%E6%8C%87%E5%8D%97%E7%9A%84-retrofit-+-coroutine-%E5%B0%81%E8%A3%85/</guid><description>&lt;h2 id="前言">前言&lt;/h2>
22
&lt;p>Retrofit 从 2.6.0 以后对 Kotlin 协程提供了原生支持,使得异步请求从写法上更像同步调用,配合 Google 出的 Jetpack 全家桶可以使得网络请求更加优雅简单,而且可以完全遵循 Google 给出的应用架构指南。&lt;/p>
33
&lt;p>另外我们有一个更加多样的需求:我们的应用使用了多套服务接口,每套接口返回的参数模板不同,baseUrl 则更多样化,因此带来了更复杂的封装逻辑。&lt;/p></description></item><item><title>时间格式化的趣事:YYYY 示年</title><link>/posts/%E6%97%B6%E9%97%B4%E6%A0%BC%E5%BC%8F%E5%8C%96%E7%9A%84%E8%B6%A3%E4%BA%8Byyyy%E7%A4%BA%E5%B9%B4/</link><pubDate>Thu, 27 Feb 2020 00:00:00 +0000</pubDate><guid>/posts/%E6%97%B6%E9%97%B4%E6%A0%BC%E5%BC%8F%E5%8C%96%E7%9A%84%E8%B6%A3%E4%BA%8Byyyy%E7%A4%BA%E5%B9%B4/</guid><description>&lt;h2 id="引言">引言&lt;/h2>
44
&lt;p>2019 年 12 月 29 到 31 日在格式化时间时出现了一个有趣的小 bug:比如 2019 年 12 月 31 日时间戳有可能会被格式化成:2020-12-31。&lt;/p></description></item><item><title>MD5 计算前导 0 丢失问题</title><link>/posts/md5%E8%AE%A1%E7%AE%97%E5%89%8D%E5%AF%BC0%E4%B8%A2%E5%A4%B1%E9%97%AE%E9%A2%98/</link><pubDate>Mon, 20 Jan 2020 00:00:00 +0000</pubDate><guid>/posts/md5%E8%AE%A1%E7%AE%97%E5%89%8D%E5%AF%BC0%E4%B8%A2%E5%A4%B1%E9%97%AE%E9%A2%98/</guid><description>&lt;h2 id="现象">现象&lt;/h2>
@@ -32,4 +32,4 @@ return new BigInteger(1, md.digest()).toString(16);
3232
&lt;p>注:本文涉及了少许 HashMap 基础,由于与主线无关,不详讲。源码均加了些注释,注释无法解释清楚的地方放在源码之后论述。&lt;/p></description></item><item><title>从阿里规约谈起-禁用 Executors 创建线程池</title><link>/posts/%E4%BB%8E%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6%E8%B0%88%E8%B5%B7-%E7%A6%81%E7%94%A8executors%E5%88%9B%E5%BB%BA%E7%BA%BF%E7%A8%8B%E6%B1%A0/</link><pubDate>Fri, 30 Aug 2019 00:00:00 +0000</pubDate><guid>/posts/%E4%BB%8E%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6%E8%B0%88%E8%B5%B7-%E7%A6%81%E7%94%A8executors%E5%88%9B%E5%BB%BA%E7%BA%BF%E7%A8%8B%E6%B1%A0/</guid><description>&lt;h2 id="前言">前言&lt;/h2>
3333
&lt;p>Android 开发中耗时任务应该放在子线程中进行,否则会阻塞 UI 造成 ANR。但是如果直接创建子线程,阿里规约会提示:&lt;/p>
3434
&lt;p>&lt;img src="https://static.fori.fun/blog/posts/img/p3c_new_thread_error.png" alt="直接使用子线程报错">&lt;/p>
35-
&lt;p>关于禁止直接创建线程的原因如图,不再赘述。&lt;/p></description></item><item><title/><link>/posts/%E6%B7%B1%E5%85%A5%E6%BA%90%E7%A0%81%E6%8E%92%E6%9F%A5-flag_activity_new_task-%E5%AF%BC%E8%87%B4%E7%9A%84-activity-%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%90%AF%E5%8A%A8/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/posts/%E6%B7%B1%E5%85%A5%E6%BA%90%E7%A0%81%E6%8E%92%E6%9F%A5-flag_activity_new_task-%E5%AF%BC%E8%87%B4%E7%9A%84-activity-%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%90%AF%E5%8A%A8/</guid><description>深入源码排查 FLAG_ACTIVITY_NEW_TASK 导致的 Activity 无法正常启动 引言 众所周知 Android 中 Activity 有四种启动模式,决定了是否创建新的 Activity 实例或复用当前实例。但是实际上 Activity 的启动十分复杂,不单单是 android:launchMode 就能</description></item></channel></rss>
35+
&lt;p>关于禁止直接创建线程的原因如图,不再赘述。&lt;/p></description></item></channel></rss>

page/2/index.html

+19-13
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<meta property="og:url" content="/">
2525
<meta property="og:description" content="Eureka is a elegant and powerful theme for Hugo.">
2626
<meta property="og:site_name" content="IO01 Blog">
27-
<meta property="og:updated_time" content="2021-06-18T00:00:00+00:00">
27+
<meta property="og:updated_time" content="2021-09-16T00:00:00+00:00">
2828
<meta property="article:section" content>
2929
<link rel=alternate type=application/rss+xml href=/index.xml title="IO01 Blog">
3030
<body class="flex flex-col min-h-screen">
@@ -68,18 +68,17 @@
6868
<div class="flex flex-col-reverse lg:flex-row justify-between">
6969
<div class=w-full>
7070
<div class=mb-4>
71-
<a href=/posts/%E4%BB%8E%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6%E8%B0%88%E8%B5%B7-hashmap%E5%88%9D%E5%A7%8B%E5%8C%96%E5%92%8C%E6%89%A9%E5%AE%B9%E7%9B%B8%E5%85%B3/ class="font-bold text-xl hover:text-eureka">从阿里规约谈起-HashMap 初始化和扩容相关</a>
71+
<a href=/posts/%E4%BB%8E%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6%E8%B0%88%E8%B5%B7-arrays.aslist%E4%B8%89%E5%9D%91/ class="font-bold text-xl hover:text-eureka">从阿里规约谈起-Arrays.asList 三坑</a>
7272
</div>
7373
<div class=content>
74-
引言 日常开发中使用 HashMap 方法如下:
75-
Map&amp;lt;String, Object&amp;gt; HashMap = new HashMap&amp;lt;&amp;gt;(); 但是阿里规约会提示有问题:
76-
由此我们可以看一下 HashMap 初始化和扩容相关。
77-
注:本文涉及了少许 HashMap 基础,由于与主线无关,不详讲。源码均加了些注释,注释无法解释清楚的地方放在源码之后论述。
74+
前言 将数组转换成 List 是日常开发十分常见的操作,对此 JDK 提供了一个非常好用的工具类:
75+
List list = Arrays.asList(array); 但是如果操纵 List 的内容的话,阿里规约会给出一个提示:
76+
于是深入看了下,发现 Arrays.asList 有三个日常开发中容易坑人的地方。
7877
</div>
7978
<div class="flex flex-wrap flex-row items-center mt-2 text-tertiary-text">
8079
<div class="mr-6 my-2">
8180
<i class="fas fa-calendar mr-1"></i>
82-
<span>2019-08-30</span>
81+
<span>2019-09-24</span>
8382
</div>
8483
<div class="mr-6 my-2">
8584
<i class="fas fa-th-list mr-1"></i>
@@ -93,11 +92,13 @@
9392
<div class="flex flex-col-reverse lg:flex-row justify-between">
9493
<div class=w-full>
9594
<div class=mb-4>
96-
<a href=/posts/%E4%BB%8E%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6%E8%B0%88%E8%B5%B7-%E7%A6%81%E7%94%A8executors%E5%88%9B%E5%BB%BA%E7%BA%BF%E7%A8%8B%E6%B1%A0/ class="font-bold text-xl hover:text-eureka">从阿里规约谈起-禁用 Executors 创建线程池</a>
95+
<a href=/posts/%E4%BB%8E%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6%E8%B0%88%E8%B5%B7-hashmap%E5%88%9D%E5%A7%8B%E5%8C%96%E5%92%8C%E6%89%A9%E5%AE%B9%E7%9B%B8%E5%85%B3/ class="font-bold text-xl hover:text-eureka">从阿里规约谈起-HashMap 初始化和扩容相关</a>
9796
</div>
9897
<div class=content>
99-
前言 Android 开发中耗时任务应该放在子线程中进行,否则会阻塞 UI 造成 ANR。但是如果直接创建子线程,阿里规约会提示:
100-
关于禁止直接创建线程的原因如图,不再赘述。
98+
引言 日常开发中使用 HashMap 方法如下:
99+
Map&amp;lt;String, Object&amp;gt; HashMap = new HashMap&amp;lt;&amp;gt;(); 但是阿里规约会提示有问题:
100+
由此我们可以看一下 HashMap 初始化和扩容相关。
101+
注:本文涉及了少许 HashMap 基础,由于与主线无关,不详讲。源码均加了些注释,注释无法解释清楚的地方放在源码之后论述。
101102
</div>
102103
<div class="flex flex-wrap flex-row items-center mt-2 text-tertiary-text">
103104
<div class="mr-6 my-2">
@@ -116,15 +117,20 @@
116117
<div class="flex flex-col-reverse lg:flex-row justify-between">
117118
<div class=w-full>
118119
<div class=mb-4>
119-
<a href=/posts/%E6%B7%B1%E5%85%A5%E6%BA%90%E7%A0%81%E6%8E%92%E6%9F%A5-flag_activity_new_task-%E5%AF%BC%E8%87%B4%E7%9A%84-activity-%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%90%AF%E5%8A%A8/ class="font-bold text-xl hover:text-eureka"></a>
120+
<a href=/posts/%E4%BB%8E%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6%E8%B0%88%E8%B5%B7-%E7%A6%81%E7%94%A8executors%E5%88%9B%E5%BB%BA%E7%BA%BF%E7%A8%8B%E6%B1%A0/ class="font-bold text-xl hover:text-eureka">从阿里规约谈起-禁用 Executors 创建线程池</a>
120121
</div>
121122
<div class=content>
122-
深入源码排查 FLAG_ACTIVITY_NEW_TASK 导致的 Activity 无法正常启动 引言 众所周知 Android 中 Activity 有四种启动模式,决定了是否创建新的 Activity 实例或复用当前实例。但是实际上 Activity 的启动十分复杂,不单单是 android:launchMode 就能
123+
前言 Android 开发中耗时任务应该放在子线程中进行,否则会阻塞 UI 造成 ANR。但是如果直接创建子线程,阿里规约会提示:
124+
关于禁止直接创建线程的原因如图,不再赘述。
123125
</div>
124126
<div class="flex flex-wrap flex-row items-center mt-2 text-tertiary-text">
125127
<div class="mr-6 my-2">
126128
<i class="fas fa-calendar mr-1"></i>
127-
<span>0001-01-01</span>
129+
<span>2019-08-30</span>
130+
</div>
131+
<div class="mr-6 my-2">
132+
<i class="fas fa-th-list mr-1"></i>
133+
<a href=/series/%E9%98%BF%E9%87%8C%E8%A7%84%E7%BA%A6/ class=hover:text-eureka>阿里规约</a>
128134
</div>
129135
</div>
130136
</div>

0 commit comments

Comments
 (0)