我有一个应用程序'A'和应用程序'B'.
说,我在应用程序'A'中有一个字符串资源
<\string name="abc">ABCDEF<\/string>
Run Code Online (Sandbox Code Playgroud)
如何从'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){
}
Run Code Online (Sandbox Code Playgroud)
始终resId总是返回0 ..任何人都可以告诉我是否可以从应用程序'B'访问字符串abc
此致,SANAT
android ×1