您的位置:首页 > 移动开发 > Android开发

android插件化框架 small对资源的支持

2016-12-02 12:06 281 查看
1:不用small 怎么获取资源

    Resouces r = context.getResources();

    获取字符串  r.getString(intValue);

    获取图片     r.getDrawable(intValue);

2:怎么获取其它package包的资源

   方法一:

   Context otherContext = context.createPackageContext(otherPackageName , Context.CONTEXT_IGNORE_SECURITY)

   Drawable result = otherContext.getResources.getIdentifier(context.getResources().getResourceName(resInt), "drawable",otherContext.getPackageName());

  

   方法二:

  通常用于跨进程获取另一个ap里面的资源

final PackageManager pm = context.getPackageManager();

ApplicationInfo ai = pm.getApplicationInfo(resPackage, PackageManager.GET_UNINSTALLED_PACKAGES);

pm.getResourcesForApplication(ai).getResources().getDrawable(getResId(), context.getTheme());


 

  方法三:见small加载资源的方式

 

3: small加载资源的方式

    resource的初始化

    关键步骤在assetPath



small中是如何做的:在插件加载完后的postSetup方法中



 


 4:为什么不能加载插件中的资源

 

notification的加载流程



icon中的loaddrawable



 是通过方法二中读取其它包的资源来读取资源的

以此类推,如果需要跨进程读取的资源,不能放到插件里面

如何支持:

stub模式

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  small