Android:自定义应用程序属性,可以通过包管理器访问吗?
为了工作,我维护一个内部“市场”,可以上传和下载新的应用程序版本。我还维护一个启动器,可以从我们的许多应用程序中进行选择并启动它们(有些是相同的应用程序,但“品牌”不同)。我目前可以使用包名称和版本代码填充此列表,但我还想添加到 SVN 分支中。
我正在考虑使用一个脚本,将分支信息作为 XML 添加到清单中作为自定义属性或作为单独的 XML 文件。理想情况下,PackageManager 可以公开访问它。这可能吗?
或者,我可以通过编程方式更改 APK 名称吗?然后我可以使用“$name - $branch”作为新名称。
For work I maintain an internal 'market' where new app releases can be uploaded and downloaded. I also maintain a launcher that can select from our many apps and launch them (some are the same app 'branded' differently). I can currently populate this list with the package name and the version code, but I would also like to add in the SVN branch.
I was thinking about having a script that would add the branch info as XML either to the manifest as a custom attribute or as a separate XML file. Ideally, this could be accessible publicly by the PackageManager. Is this possible?
Alternatively, can I programmatically change the APK name? Then I could use "$name - $branch" as the new name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已将
元素添加到组件的元素(例如
),并通过PackageManager
访问元数据 XML 内容code>:组件将通过如下代码访问元数据:
然后,您的自定义构建过程可以调整
指向的 XML 资源以包含您想要的任何内容。您可以在硬盘上随意命名 APK 文件,但我不会指望该名称在安装过程中保持不变。
You have add a
<meta-data>
element to a component's element (e.g.,<activity>
) and access the metadata XML content viaPackageManager
:The component would access the metadata through code like this:
Your custom build process could then adjust the XML resource pointed to by
<meta-data>
to contain whatever you want.You can name the APK file whatever you want on your hard drive, but I would not count on that name remaining intact through the installation process.