Re: [問題] Intent傳遞複雜參數
※ 引述《mysteriousGE ( )》之銘言:
: 標題: [問題] Intent傳遞複雜參數
: 時間: Thu Aug 16 11:53:23 2012:
: --
: ※ 發信站: 批踢踢實業坊(ptt.cc)
: ◆ From: 60.251.187.178
: 推 mongsq:gson 08/16 12:00
: 推 givemepass:singleton 08/16 12:15
: → iincho:我是覺得乖乖的去實作Parcelable比較好... 08/16 23:33
: 推 weruioi:singleton或放在其他static的地方會有可能拿不到 08/16 23:37
: → weruioi:parcelable比較實在 08/16 23:37
: 推 ivanf10710:建立一個class extends Applicaition,複雜的參數都往 08/17 00:55
: → ivanf10710:這邊丟,但是記得同一個物件要使用在不同的地方時,要 08/17 00:56
: → ivanf10710:去清他, 08/17 00:56
: → ivanf10710:http://oyeal.iteye.com/blog/941183 看看這篇吧 08/17 00:58
塞Application這個方法可能在跨Process上會有問題.
(雖然Android上你看到的都是Activity,實際上可能跑在不同process上)
不過扯到可能會過Binder IPC的東西,最終都會被攤平成一塊記憶體往
driver丟,所以實作Parcelable是必要的,不然你的東西過了IPC就再見了。
--
Beware of bugs in the above code;
I have only proved it correct, not tried it.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.193.107
推
08/17 14:47, , 1F
08/17 14:47, 1F
推
08/17 18:44, , 2F
08/17 18:44, 2F
討論串 (同標題文章)