[問題] static vs Application
如果要在整個app中使用全域變數
方法有直接使用class的public static
或是使用Application,整個app只有一個instance
但是如果使用Application,就只能在Activity中使用getApplication()
但是用public static的話則到處都可以使用
那麼Application和static的使用時機為何?
--
I'm not the only one,
To crash into the sun, and live to fight another day.
Like a super nova, that old life is over.
I'm here to stay. Now I'm gonna be,
Invincible.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.89.183
推
07/17 21:30, , 1F
07/17 21:30, 1F
→
07/17 21:31, , 2F
07/17 21:31, 2F
→
07/17 21:32, , 3F
07/17 21:32, 3F
→
07/18 15:34, , 4F
07/18 15:34, 4F
→
07/18 15:34, , 5F
07/18 15:34, 5F
→
07/18 15:34, , 6F
07/18 15:34, 6F
AndroidDev 近期熱門文章
PTT數位生活區 即時熱門文章