简体   繁体   中英

Detect the source of apk download

I have an apk file present in 2 standalone servers both of which have separate download links.

I would like to know if it is possible to detect from which link the apk was downloaded after the app was installed and opened. The download is via browser and the one of the requirements is that the build has to remain the same.

If you are just installing your APK as a link directly on a file server, and the APKs are exactly the same, then no, there is no way to do this.

Here are some work-arounds:

  1. Google Play provides a way for you to do this , but they are doing this through broadcasting an intent to the application after it has been successfully installed. You could release the APKs through Google Play privately through the beta / alpha channel, and take advantage of this feature perhaps. You'd not be able to use a private file server though.
  2. You could create your own application that downloads and installs the APKs and mimics Google Play's functionality which I described above. This would probably be ridiculous for you to do, and I don't recommend it.
  3. You could differentiate the APKs in some way. You could keep the content exactly the same, but configure some fields in the build logic through Gradle using the buildConfigField . You could also do split apks, use flavors, or a number of other different creative solutions if you wish.
  4. So if for some reason the above suggestions don't meet your requirements, another solution that would be extremely hacky would be to use different APK file names. The browser would download the APK to the download folder, and you could probably look at the Android download s folder after opening the app and look at the file name. This would not be reliable in any way though, as users could easily delete the file before actually opening your app, or there could be old downloads also. You'd have to look for base file names, and identify the most recent file based on creation date.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM