简体   繁体   English

检测apk下载的来源

[英]Detect the source of apk download

I have an apk file present in 2 standalone servers both of which have separate download links. 我在2个独立服务器中都有一个apk文件,两个服务器都有单独的下载链接。

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. 我想知道在安装和打开应用程序后,是否有可能检测到从哪个链接下载了apk。 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. 如果您只是将APK作为链接直接安装在文件服务器上,并且APK完全相同,那么就没有办法做到这一点。

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. Google Play 为您提供了一种方法 ,但是他们是通过在应用程序成功安装后向其广播意图来实现的。 You could release the APKs through Google Play privately through the beta / alpha channel, and take advantage of this feature perhaps. 您可以通过Beta / alpha通道通过Google Play私下发布APK,也许可以利用此功能。 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. 您可以创建自己的应用程序,该应用程序可以下载并安装APK,并模仿我上面所述的Google Play的功能。 This would probably be ridiculous for you to do, and I don't recommend it. 您这样做可能很荒谬,我不建议您这样做。
  3. You could differentiate the APKs in some way. 您可以通过某种方式区分APK。 You could keep the content exactly the same, but configure some fields in the build logic through Gradle using the buildConfigField . 您可以保持内容完全相同,但是可以使用buildConfigField通过Gradle在构建逻辑中配置一些字段。 You could also do split apks, use flavors, or a number of other different creative solutions if you wish. 如果愿意,您也可以拆分apk,使用样式或其他许多不同的创意解决方案。
  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. 因此,如果由于某些原因上述建议不符合您的要求,则另一个非常棘手的解决方案是使用不同的APK文件名。 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. 浏览器会将APK下载到download文件夹,打开应用程序并查看文件名后,您可能会查看Android download的文件夹。 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. 您必须寻找基本文件名,并根据创建日期确定最新文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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