以编程方式确定正在运行的 APK(或 DEX)的文件名?

发布于 2024-08-26 20:05:38 字数 236 浏览 3 评论 0原文

我想在从我的网站(而不是来自市场)分发 APK 时即时嵌入特定于用户的数据。

我目前的想法只是在 APK 文件名中嵌入一个唯一的 ID。这很简单,更改文件名不会破坏代码签名。我当前的问题是尝试检索文件名(APK 或 DEX),以便我可以读取此 ID。

我已经尝试了大多数标准方法 - 浏览 PackageInfo、ApplicationContext、ProtectionDomain,但我似乎无法让任何东西起作用。有想法吗?

I would like to embed user-specific data on-the-fly when distributing an APK from my website (NOT from the Market).

My current idea is simply to embed a unique ID in the APK filename. This is simple enough and changing the filename doesn't break the code signing. My current issue is trying to retrieve the filename (APK or DEX) so that I can read this ID.

I've tried most of the standard methods -- poking around PackageInfo, ApplicationContext, ProtectionDomain but I can't seem to get anything to work. Ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彩虹直至黑白 2024-09-02 20:05:38

APK 文件名在 Android 中没有多大意义。我并不感到非常惊讶 PackageInfo 中没有它的位置。我什至不知道 APK 文件是否以其原始名称存储在设备上。

APK filenames don't have much meaning in Android. I am not terribly surprised there is no spot in PackageInfo for it. I don't even know if the APK file is stored on the device under its original name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文