获取的另一个应用程序资源 [英] Getting resources of another Application

查看:111
本文介绍了获取的另一个应用程序资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有2应用程序A和B

Assume I've got 2 Application A and B.

我想从一个应用程序访问B应用的资源(可绘制图像,字符串)。我将如何做呢?

I want to access resources (drawables, images, strings) of an B application from A application. How would I do that?

编辑:

您也可以指定一个Android项目作为库项目,这使得它能够与依赖于它的其他项目共享。一旦Android项目被指定为库项目,它不能被安装到设备上。

You can also designate an Android project as a library project, which allows it to be shared with other projects that depend on it. Once an Android project is designated as a library project, it cannot be installed onto a device.

这是否意味着我不能在Android市场上使用我的图书馆? 我的目标是使用应用程序A的默认资源,而且如果有人有什么他可以下载应用程序B,并使用它的资源。

Does it mean That I can not use my library on android market? My aim is to use default resources of Application A, but also if someone what he can download Application B and use it resources.

推荐答案

如果你是这两个应用程序的开发者那么正确的做法是,为othes指出,建立一个Android库项目和应用程序之间共享。

If you are the developer of both applications then the right approach would be, as othes noted, to create an Android library project and share it between apps.

Nevertheles,你仍然可以从其他应用程序访问的资源,即使这是不是你的应用程序:

Nevertheles, you can still access resources from another app, even if this is not your app:

Resources res = context.getPackageManager().getResourcesForApplication("com.example.foo")

这篇关于获取的另一个应用程序资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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