【问题标题】:How to get the expansion file URL?如何获取扩展文件的 URL?
【发布时间】:2021-01-08 08:46:55
【问题描述】:

如果用户删除了扩展文件,如何从 google play 获取扩展文件 URL 以下载文件。

【问题讨论】:

    标签: android google-play android-download-manager apk-expansion-files expansion-files


    【解决方案1】:

    您必须使用LicenseChecker 来获取扩展文件的 URL、名称或大小。

      private LicenseChecker mChecker;
      private String expFileUrl;
    

    MainActivity 上使用此方法:

     private void setLicenseChecker() {
            String deviceId = android.provider.Settings.Secure.getString(this.getContentResolver(),
                    android.provider.Settings.Secure.ANDROID_ID);
    
            final APKExpansionPolicy aep = new APKExpansionPolicy(this,
                    new AESObfuscator(SALT, this.getPackageName(), deviceId));
    
            // reset our policy back to the start of the world to force a
            // re-check
            aep.resetPolicy();
    
            // let's try and get the OBB file from LVL first
            // Construct the LicenseChecker with a Policy.
            mChecker = new LicenseChecker(this, aep,BASE64_PUBLIC_KEY);
    
            mChecker.checkAccess(new LicenseCheckerCallback() {
                @Override
                public void allow(int reason) {
                    expFileUrl=aep.getExpansionURL(0);
                    Log.d(LOG_TAG, "Obb name:"+aep.getExpansionFileName(0));
                    Log.d(LOG_TAG, "Obb size:"+aep.getExpansionFileSize(0));
                    Log.d(LOG_TAG, "Obb Url:"+aep.getExpansionURL(0));
                    Log.d(LOG_TAG, "Obb Count:"+aep.getExpansionURLCount());
                }
                @Override
                public void dontAllow(int reason) {
                }
                @Override
                public void applicationError(int errorCode) {
                }
            });
        }
    
     @Override
        protected void onDestroy() {
            super.onDestroy();
            mChecker.onDestroy();
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-14
      • 2014-04-14
      • 1970-01-01
      • 2014-07-01
      • 2012-07-23
      • 2017-12-22
      • 1970-01-01
      • 2020-12-10
      相关资源
      最近更新 更多