是否可以在不使用内容提供程序的情况下访问另一个 APK 中的资源?
我认为除非使用内容提供程序,否则不可能访问其他APK中包含的资源。然而,我偶然发现了一个名为“更好的键盘”的应用程序。它使用皮肤,所以我决定下载一个皮肤示例。
示例皮肤着实令我惊讶。它几乎不包含任何代码,仅声明一个活动而没有内容提供者。尽管如此,它仍然包含资源,并且如果安装了带有皮肤的 APK,显然可以通过 Better Keyboard 应用程序访问它们。那么它是如何做到的呢?
I thought that it is impossible to access resources contained in other APK unless content providers are used. However, I stumbled upon an app called Better Keyboard. It uses skins, so I decided to download an example of a skin.
An example skin really surprised me. It contains almost no code, declares only an activity and no content providers. Nontheless it contains resources and they are apparently somehow accessed from Better Keyboard app if the APK with the skin gets installed. So how is it done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信您正在寻找
Resources res = mPackageManager.getResourcesForApplication("org.example.foo");
http://developer.android.com/reference/android/content/pm/PackageManager.html#getResourcesForApplication%28java.lang .字符串%29
I believe you're looking for
Resources res = mPackageManager.getResourcesForApplication("org.example.foo");
http://developer.android.com/reference/android/content/pm/PackageManager.html#getResourcesForApplication%28java.lang.String%29
试试这个
Try this
可以使用
getresoucesforapplication
,并且您需要res.getidentifier
来检索资源ID。但是,在检索样式资源时它似乎不起作用。It is possible by using
getresoucesforapplication
and you needres.getidentifier
to retrieve the resource Id. However, It seem not work when retrieving style resource.