android - 在应用程序之间共享可绘制对象

标签 android android-resources

我已经在我的应用程序中实现了插件系统。插件作为独立应用程序存在。

从主应用程序中的插件访问可绘制对象的最佳方式是什么?

最佳答案

你有几个选择:

  • ContentProvider - 不一定需要基于 SQLite 数据库。

  • list 属性android:sharedUserId

    来自文档:

    The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process.

    参见 http://developer.android.com/guide/topics/manifest/manifest-element.html#uid

  • PackageManager.getResourcesForApplication()检索与应用程序关联的资源。

    用法:

    PackageManager pm = getPackageManager();
    try {
        Resources resources = pm.getResourcesForApplication("com.example.app");
        int id = resources.getIdentifier("ic_launcher", "drawable", "com.example.app");
        Drawable d = resources.getDrawable(id)
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    

关于android - 在应用程序之间共享可绘制对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11626359/

相关文章:

java - ANDROID:回收者 View 内的多个卡片 View

android - FireBase 云消息传递是否需要 Play 服务?

Android - 将 GestureDetector 添加到 webview

android - android中不可绕过的root检测方法

android - 使用 Floating Window Manager App 在连续点击时崩溃

android - Android apk 构建的条件资源包含/排除

android - 如何使用 TypedArray 获取 Drawable(带有 drawable 别名)

android - Android 翻译工具,协助提供上下文

更新到 3.2 后的 Android Gradle 错误

java.lang.NoClassDefFoundError : android. support.v7.mediarouter.R$string