第一次執行APP,按Home後,無法回到上次狀態,再回到APP總是啟動 MainActivity
APP結構如下:
APP共有 Activity A 與 Activity B
點 A 的 item 會啟動 Activity B
問題發生情境:
由 google 商店下載,或者是手動安裝 apk 的 app
第一次啟動 APP 後,點選 Activity A 中的 item 啟動了 Activity B
此時按 Home 鍵離開 APP
再次點選 APP 後,卻出現 Activity A
正常的情況下:
當點選 Activity A 的 item 並啟動 Activity B 以後,接著按下 Home 鍵會離開 APP 並回到手機桌面
當再次點選 APP 時,理論上應該要出現 Activity B
當問題發生時
但是此時點選 Back 鍵時,又會跳出 Activity B
再點一次 Back ,就會跳回Activity A
再點一次 Back,就跳回手機桌面
在這之後,一切都開始正常運作了
也就是問題情境只會發生在剛下載 APP 後的第一次執行
解法就是
在 Activity A 的 onCreate() 內
加入已下程式碼即可
[sourcecode language=”JAVA”]
<pre>if (!isTaskRoot()) {
final Intent intent = getIntent();
final String intentAction = intent.getAction();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) &&
intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) {
finish();
}
}
[/sourcecode]
資料來源參考: https://code.google.com/p/android/issues/detail?id=2373
Thanks for the information, very useful for me, follow us me “majalahtelanjang.info
Thanks for the information, very useful for me, ALITOGEL.COM | Agen Togel Singapore Terpercaya Indonesia
With havin so much content and articles
do you ever run into any issues of plagorism or copyright violation? My site has a lot
of exclusive content I’ve either written myself or outsourced but it appears a
lot of it is popping it up all over the web without my authorization. Do you know any solutions
to help stop content from being ripped off? I’d genuinely appreciate it.
Simply want to say your article is as surprising.
The clarity on your publish is simply nice and that i can suppose
you are a professional on this subject. Well together with your permission allow
me to snatch your feed to stay up to date with
imminent post. Thanks 1,000,000 and please carry on the gratifying work.
Hi there, the whole thing is going perfectly here and ofcourse every one is sharing data, that’s actually fine, keep
up writing.
Appreciating the commitment you put into your blog and
detailed information you offer. It’s great to come across a blog every once in a
while that isn’t the same unwanted rehashed information. Fantastic read!
I’ve saved your site and I’m including your RSS feeds to my Google
account.
Thanks a lot for sharing this with all people you really
recognize what you’re talking approximately! Bookmarked. Kindly additionally seek advice from my web site
=). We may have a link alternate agreement among us
I am genuinely glad to read this webpage posts which contains tons of useful facts, thanks for
providing these kinds of statistics.
Programa teve 3 sessões de 10 minutos por semana. https://Jimvoorhies.com/efeitoscolateraishbfv594/lineshake-funciona/
What’s up to every body, it’s my first pay a quick visit of this webpage;
this webpage contains awesome and in fact good
materiial in favor off readers.
I think this is one of the such a lot vital info for me.
And i’m happy studying your article. But wanna remark on few basic things, The site taste
is perfect, the articles is in reality nice : D.
Good task, cheers
I enjoy looking through an article that will make people think.
Also, thank you for allowing for me to comment!
Helⅼo my family member! I want tto ѕay that this article is amazing, great written and
come with approximately aⅼl importznt infos.
I’d like to lkok more posts like thiѕ . https://sablonkaossatuanbandung88.blogspot.com/
1. More practical marketing and extra profits.