我现在开发2个APP 为: A.apk    B.apk这个程序,通过指定:android:sharedUserId="com.xxxx.plugin"
实现在2APP 共用一个uid。我现在想从A.apk 使用B.apk中的资源文件,怎么办,能实现吗?比如:B.apk 中有 raw/comm.xml,我希望A.apk能获取使用。这样,我的comm.xml改变,只要升级B.apk就可以了。

解决方案 »

  1.   


    public abstract Resources getResourcesForApplication (String appPackageName)
      

  2.   

    http://blog.sina.com.cn/s/blog_6714fba701018k8h.html
      

  3.   

    这只是获取本身apk中的资源,我这是想获取关联的另外一个apk资源
      

  4.   

    自己解决了:
    Context slaveContext = null;     
            try {     
                slaveContext = convertView.getContext().createPackageContext(     
                        "com.carnurse.plugin.laws",Context.CONTEXT_IGNORE_SECURITY);     
            } catch (NameNotFoundException e) {     
                e.printStackTrace();     
            }  
            int resID = slaveContext.getResources().getIdentifier("ic_launcher", "drawable", "com.carnurse.plugin.laws");   
            holder.ivIcon.setImageDrawable(slaveContext.getResources().getDrawable(resID));