在果冻豆访问其他Android应用程序资产果冻、应用程序、资产、Android

2023-09-05 09:24:32 作者:说忘.

我有一双的Andr​​oid应用程序。一个是免费的阅读器的应用程序,另一个是在其资产子目录支付的数据应用程序,用一个文本文件中。

I have a pair of Android apps. One is a free 'reader' app and the other is a paid for 'Data' app with a text file in a sub directory of its assets.

阅读器应用程序使用下面的code来访问数据的应用程序的文本文件:

The reader app uses the following code to access the data app's text file:

Intent myIntent = new Intent("myintent");
List<ResolveInfo> dataPacks = packageManager.queryIntentActivities(myIntent, 0);
String packageName = dataPacks.get(0).activityInfo.packageName
Resources res = packageManager.getResourcesForApplication(packageName);
AssetManager assets = res.getAssets();
String[] dataFiles = assets.list("Data");

这一直工作正常,但使用谷歌Play应用下载到果冻豆不工作(数据文件是空的)。如果应用程序是从电子邮件直接安装就罚款,所以我怀疑我的问题是涉及到最近的安全变为谷歌播放。然而,这些据称被撤消,但我仍然有问题。

This has been working fine but apps downloaded to Jelly Bean using Google Play are not working (datafiles is empty). If the app is installed directly from email it is fine so I suspect my problem is related to the recent security changes to Google Play. However, these have allegedly been undone but I am still having problems.

任何人都可以揭示的是什么问题呢? (遗憾的是我没有一个果冻豆的设备)

Can anybody shed light on what is going wrong? (unfortunately I dont have a Jelly Bean device)

另外,可有人提出一个更好的机制来访问数据应用程序的TXT文件?

Alternatively, can somebody suggest a better mechanism for accessing the data app's txt file?

感谢

推荐答案

在JB设备付费应用是向前锁定。这意味着,APK被分成两部分 - 一部分公共资源,和一个与私立学校和code,这是不被其他应用程序读取。这里的一些细节: HTTP://nelenkov.blogspot .COM / 2012/07 /使用应用内加密功能于果冻bean.html

Paid apps on JB devices are 'forward locked'. This means that the APK is split in two parts -- one with public resources, and one with private ones and code, which is not readable by other apps. Some details here: http://nelenkov.blogspot.com/2012/07/using-app-encryption-in-jelly-bean.html

我还没有研究文件如何被分割的细节,但您所看到的问题表明,资产专用APK,这是有道理的一部分,因为你通常坚持API密钥等资产。

I haven't looked into how files are split in detail, but the problem you are seeing suggests that assets are part of the private APK, which makes sense, since you typically stick API keys, etc in assets.

因此​​,你需要用一个比较间接的方法来共享两个应用程序之间的信息,如ContentProvider的或远程的服务。请确保您需要签字的权限来访问这些,以确保只有你自己的应用程序可以使用它们。

So you need to use a more indirect method to share info between the two apps such as a ContentProvider or remote service. Make sure you require signature permissions to access those, to make sure only your own apps can use them.