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

    xiaoxiao2021-12-14  27

    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模式

     

     

    转载请注明原文地址: https://ju.6miu.com/read-963179.html

    最新回复(0)