enhancementhelp wanted疑难杂症
Description
前提: lib.style 有资源 test_resource
lib.utils UIUtils.java
public static void testResource(Context context) {
int c1 = context.getResources().
getIdentifier("test_resource", "string", "net.wequick.example.small");
int c2 = context.getResources().
getIdentifier("test_resource", "string", "com.example.mysmall.lib.style");
Toast.makeText(context, c1 + " " + c2, Toast.LENGTH_SHORT).show();
Toast.makeText(context, c1 + " " +
context.getResources().getResourceEntryName(c2), Toast.LENGTH_SHORT).show();
}
现象: c1得不到资源id,c2可以。
期望: c1能得到资源id
项目中一个第三方库内部使用了这个方法,但是getIdentifier第三个参数它默认传的是context.getPackageName, 故找不到资源。