Android扩展类方法,静态方法与类扩展android.app.Application?

My original plan was to use a shared class with static methods and variables but I read a lot of “don’t do that” threads so decided to go the Application route.

“不要那样做”通常是针对全局范围内的任何内容的建议,因此将涵盖静态数据成员以及自定义应用程序.两者都可能是内存泄漏的来源.

Now, I’ve run into a situation where I’m trying to use myAppClass in a Project Library but getting errors about android.app.Application cannot be cast to…

您在托管项目中的清单可能并未声明使用库的Application实现.

this is supposed to be a big no-no

同样,静态数据成员并不比自定义应用程序差,并且在许多情况下更好.

Is there another way to do this?

不要使用应用程序或静态数据成员.

Would I be better off to re-implement the entire application by passing huge (thousands of objects/members) ArrayLists back-and-forth between methods/classes?

拥有持久数据模型(例如数据库)会更好.使用静态数据成员作为持久数据模型的缓存是可以的,只要您对内存管理非常小心.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值