在应用程序之间共享绘图 [英] Share drawables between applications

查看:86
本文介绍了在应用程序之间共享绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have implemented plugin system in my applications. Plugins exist as the standalone applications.

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

What is the best way to access drawables from plugins in main application ?

推荐答案

您几乎没有选择:

  • ContentProvider - not definitely need to be based over SQLite database.

清单属性android:sharedUserId

来自文档:

将与其他用户共享的Linux用户ID的名称 应用程序.默认情况下,Android为每个应用程序分配自己的应用程序 唯一的用户ID.但是,如果将此属性设置为相同的值 对于两个或多个应用程序,它们将共享相同的ID- 前提是它们也使用相同的证书签名. 具有相同用户ID的应用程序可以访问彼此的数据,并且 可以按照相同的流程运行.

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.getResourcesForApplication() to retrieve the resources associated with an application.

用法:

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();
}

这篇关于在应用程序之间共享绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆