两个相同APK软件包可能吗? [英] Two Packages in Same APK possible?

查看:215
本文介绍了两个相同APK软件包可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现共享preferences这个伟大的技术跨越两个不同的应用程序,同时还MODE_PRIVATE。

我的问题是,第一个应用程序不能认为第一个应用程序安装(反之亦然)等等:

 上下文C = createPackageContext(com.app.first,MODE_PRIVATE);

必须被替换为:

 上下文C = createPackageContext(com.app.shared,MODE_PRIVATE);

但是,这任务并称 com.app.shared 真实的,换算成第二个APK?

在换句话说,有只有一个 的Andr​​oidManifest.xml 每个APK和仅一个 <表明包=> 每页清单文件。因此只有一个每个APK实际的包?

我不希望每个应用程序的APK 2,我只希望每个应用程序的单个APK。

有没有办法实现这一目标?


解决方案

  

我想在两个不同的应用程序来实现共享preferences这个伟大的技术,同时还MODE_PRIVATE。


其实,就是这样一个反很好的技术,我只是删除了我的答案。使用的android:sharedUserId 是有风险的,和已经部署的应用程序完全不可能的。我了解到我在两年的方式错误,因为我已经张贴了我的答案在那里。

此外,该技术并不可靠地工作,因为你无法控制哪些应用程序在用户安装......和卸载。如果借助于应用程序A和应用B股preferences都使用App A的副本,那么当用户卸载应用程序A,应用B的大清洗。


  

因此​​只有一个每个APK实际的包?


正确的。


  

我不希望每个应用程序的APK 2,我只希望每个应用程序的单个APK。


有关两个应用程序,你有两个APK文件,每个都有自己的包名。

I am trying to implement this great technique of sharing preferences across two different applications while still MODE_PRIVATE.

My problem is that the first application cannot assume that the first application is installed (and vice versa) and so:

 Context c = createPackageContext("com.app.first", MODE_PRIVATE);

Must be replaced by:

 Context c = createPackageContext("com.app.shared", MODE_PRIVATE);

But that mandates adding that com.app.shared for real, which translates into a second APK?

In other words, there is only one AndroidManifest.xml per APK and only one <manifest package= > per manifest file. Therefore only one actual package per APK?

I don't want 2 APKs per application, I only want a single APK per application.

Is there a way to achieve this?

解决方案

I am trying to implement this great technique of sharing preferences across two different applications while still MODE_PRIVATE.

Actually, that is such an anti-great technique that I just deleted my answer. Using android:sharedUserId is risky, and downright impossible for already-deployed apps. I learned the error of my ways in the two years since I had posted my answer there.

Also, the technique doesn't work reliably, because you have no control over which apps the user installs... and uninstalls. If App A and App B share preferences by means of both using App A's copy, then when the user uninstalls App A, App B is hosed.

Therefore only one actual package per APK?

Correct.

I don't want 2 APKs per application, I only want a single APK per application.

For two applications, you have two APK files, each with their own package name.

这篇关于两个相同APK软件包可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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