如何获取扩展文件的URL



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

您必须使用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();
}

相关内容

  • 没有找到相关文章

最新更新