【发布时间】:2016-12-20 03:57:30
【问题描述】:
我需要从 Context 对象不可用的某个地方的资源中获取字符串。我可以将上下文对象作为参数传递并从资源中获取字符串,如下所示:
context.getString(R.string.some_string);
但我也可以像这样使用我的Application (extends Application) 实例:
MyApplication.getInstance().getResources().getString(R.string.some_string)
第二种方法有什么缺点吗?
【问题讨论】:
标签: android android-resources android-context