Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

android - Install a GooglePlay located App from NFC

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. 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 ?

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 - 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 - 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 - 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:

  • At first my App did not appear anywhere in the local PlayStore App, but when I searched for it in Google Play, it showed up with the green "installed" badge, and it proposed me to make an update... So did I.
  • Then, after this first manual update, the App is in v2, nice, and better: it appears well listed in my PlayStore.
  • Optimistically, I uploaded a v3 of the App... just to see if my PlayStore would automatically update my app (as is does for all the other ones), but sadly no luck : even if my app is still listed in the playstore, and proposing the "update" button... it never updates by itself as it should ; I still need to click on it manually.

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);
        }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Write your package name as an AAR record in the tag.

To confirm that this functionality works, use this app to write the tag with.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...