【发布时间】:2014-04-08 15:34:22
【问题描述】:
我的主要想法是在两个应用程序之间共享资源。 我正在使用下面的代码来获取字符串项,但是当我对字符串数组执行相同操作时,它总是返回 0(它找不到资源):
String packageName = "com.example.mymainapp.mymodule.app.libs";
Resources res = getPackageManager().getResourcesForApplication(packageName);
int resourceId = res.getIdentifier(packageName + ":string/items", null, null);
我也尝试过:
int resourceId = res.getIdentifier(packageName + ":array/items", null, null);
和
int resourceId = res.getIdentifier(packageName + ":string/items", "array", null);
和
int resourceId = res.getIdentifier("items", "array", null);
感谢任何帮助。
【问题讨论】:
-
你试过
int resourceId = res.getIdentifier("items", "array", packageName);吗? -
是的,我做到了。但仍然返回 0。
-
并且安装了这个包标识的应用?
-
是的,当然,我已经从中检索到了简单的字符串资源。
-
能贴出数组xml声明的相关部分吗?
标签: android resources share arrays