2

初学 Android,请教下关于 context 的问题

 2 years ago
source link: https://www.v2ex.com/t/823505
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Android

初学 Android,请教下关于 context 的问题

  Features · 17 小时 47 分钟前 · 1267 次点击
我在 Service 使用 Context.getAssets()
需要将 Activity.this 传入到 Service 中
因为 Activity 在退出程序后,就会 destroyed()
我担心传入 Service 的 Context 会跟随被销毁
但经过我监测,实际运行中并没有被销毁
这是什么原因呢?

这种情况是可靠的吗? Context 总是不会被销毁吗?

第 1 条附言  ·  11 小时 1 分钟前

有些问题想再请教下大家:
我做的是一个音乐播放器的 demo ,Service 在不断地更新播放器的 Seekbar ,也涉及到对 Seekbar 实例的调用
按理说应用到后台以后,Seekbar 实例就被销毁了,这时候是不是也会导致内存泄漏?

第 2 条附言  ·  7 小时 13 分钟前

我看 Profiler 里,MyActivity 只是 stopped ,saved ,没有 destroyed
这说明什么呢?
我通过任务管理器杀死进程以后,Profiler 里的 MyActivity 才出现 destroyed

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK