我有两个应用程序'A'和'B'。
假设,我在应用程序'A'中有一个字符串资源
<\string name="abc">ABCDEF<\/string>
我如何从'B'中的Activity访问abc的值。
我尝试了以下方法。
try {
PackageManager pm = getPackageManager();
ComponentName component = new ComponentName(
"com.android.myhome",
"com.android.myhome.WebPortalActivity");
ActivityInfo activityInfo = pm.getActivityInfo(component, 0);
Resources res = pm.getResourcesForApplication(activityInfo.applicationInfo);
int resId = res.getIdentifier("abc", "string", null);
}
catch(NameNotFoundException e){
}
始终返回0,无论什么情况下都是resId。请问我是否可以从应用程序“B”访问字符串abc?
谢谢, SANAT