从 NFC 安装位于 GooglePlay 的应用程序 [英] Install a GooglePlay located App from NFC

查看:51
本文介绍了从 NFC 安装位于 GooglePlay 的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Lollipop,我有一个 device-owner 应用程序,它在配置时安装了 NFC.
我现在需要的是处理我的应用程序的自动更新,从 Google Play 到依赖标准的 Android 应用程序更新系统......

Working with Lollipop, I have a device-owner app that is installed with NFC at provision time.
What I need now is to handle automatic updates for my App, from Google Play to rely on the standard Android App update system...

到目前为止,我可以想象两种方法来完成这项工作,但不知道如何处理它们中的任何一种:

So far I can imagine 2 ways to get this done, but don't know how to handle any of them :

  1. 在我的 NFC 中安装常量 EXTRA PROVISIONING DEVICE ADMIN PACKAGE下载位置 直接从 Play 商店安装应用程序,而不是在我自己的开发服务器上安装 url.
    然而这个常量需要处理一个apk文件的url,我没有找到直接从 Play 商店获取 apk 安装的官方方式?(因为它会将来成为一个生产应用程序我对黑客不感兴趣)
  2. 继续从开发服务器安装 apk,但随后允许应用与位于 Play 商店的弟弟一起更新自己具有相同的包名称.
    换一种说法:这是否可以从自定义位置安装 v1 apk,然后在 PlayStore 上放置 v2……让魔法成真?
  1. in my NFC install constant EXTRA PROVISIONING DEVICE ADMIN PACKAGE DOWNLOAD LOCATION install the App directly from the Play Store instead of the url on my own dev server.
    However this constant need to handle the url of an apk file, and I did not find any official way to get apk install direct from Play Store ? (as it will be a production App in the future I'm not interested in hacks)
  2. keep installing the apk from the dev server, but then allow the App to update itself with its little brother located on the Play Store with the same package name.
    To say it an other way: Would this be possible to install a v1 apk from a custom location, then put a v2 on the PlayStore... and let the magic come true ?

如果有人可以分享有关此类程序的经验,我会很高兴.谢谢阅读!


编辑在@Stephan Branczyk 建议我可以进行更多测试之后,这是我所做的和结果:

I'd be glad to hear if anyone could share experience about such procedures. Thanks for reading!


EDIT after @Stephan Branczyk suggestion I could make some more testing, here is what I did and the results:

1 - 在 NFC 配置中,我将 apk 网址替换为snep://my.app.packagename 没有运气;它只是给出一个错误没有太多解释.

1 - In the NFC provisioning I replaced the apk url with snep://my.app.packagename without luck ; it just gives an error without much explanation.

2 - 我用这样的 PlayStore 链接替换了这个网址:https://play.google.com/store/apps/details?id=my.app.packagename 但是无论我在本地使用校验和,它都会给出校验和错误计算,或在 GooglePlay apk 详细信息中给出的校验和.它看起来离目标不远,但我无法让它发挥作用.

2 - I replaced this url by such a PlayStore link : https://play.google.com/store/apps/details?id=my.app.packagename but it gives a checksum error whether I use the checksum locally computed, or the checksum given on the GooglePlay apk details. It looks not so far from the goal but I could not make it work.

3 - 最后我回到了我的第一个解决方案,一个自托管的 apk版本 1 ......但这次我尝试在 PlayStore 上放一个更新的该应用程序的第 2 版具有完全相同的包名...这导致了我对奇怪的事情:

3 - Finally I came back on my first solution, a self-hosted apk versioned 1... but this time I tried to put on the PlayStore a newer version 2 of the app with the exact same packagename... That led me to strange things:

  • 一开始我的 App 并没有出现在本地 PlayStore App 的任何地方,但是当我在 Google Play 中搜索它时,它显示为绿色已安装"徽章,它建议我进行更新......我也是.
  • 然后,在第一次手动更新之后,该应用程序是 v2,很好,并且更好:它在我的 PlayStore 中列出得很好.
  • 乐观地说,我上传了一个 v3 的应用程序...只是想看看我的PlayStore 会自动更新我的应用程序(就像所有其他的),但遗憾的是没有运气:即使我的应用程序仍然列在Playstore,并提出更新"按钮......它永远不会自行更新;我仍然需要手动点击它.

这不是一种奇怪的行为吗?如果有人对此有想法,我真的需要能够依赖 Play 商店的功能,但到目前为止还没有运气,而且我无法相信 Device-Owner 应用程序分发与 PlayStore 不兼容?

Isn't it a strange behavior ? If some have ideas about it, I would really need to be able to rely on the Play Store functionalities but so far no luck, and I cannot believe that Device-Owner app distribution is not compatible with PlayStore ?

以防万一,仅供参考,这是我正在使用的那种配置代码:

Just in case, FYI here is the kind of provisioning code I'm using:

try {
            Properties p = new Properties();

            p.setProperty(
                    DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,
                    "my.app.packagename");
            p.setProperty(
                    DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION,
                    "http://www.example.com/myDeviceOwnerApp.apk");
            p.setProperty(
                    DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM,
                    "U55o3fO0cXQtUoQCbQEO9c_gKrs");

            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            OutputStream out = new ObjectOutputStream(bos);
            p.store(out, "");
            final byte[] bytes = bos.toByteArray();

            NdefMessage msg = new NdefMessage(NdefRecord.createMime(
                    DevicePolicyManager.MIME_TYPE_PROVISIONING_NFC, bytes));
            return msg;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

推荐答案

需要在apk中设置Base64编码的SHA1或SHA256(从M向前)

You need to set Base64 encoded SHA1 or SHA256 (from M forward) of the apk in the

EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM

通过 NFC 配置时的字段,否则配置的设备将不接受下载 URL.

field when provisioning through NFC otherwise the provisioned device will not accept the URL for download.

另请参阅此答案以正确编码校验和.

Also see this answer for properly encoding the checksum.

这篇关于从 NFC 安装位于 GooglePlay 的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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