0

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

4

1 回答 1

0

您必须使用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();
    }
于 2020-09-22T08:44:55.087 回答