如何解决如何获取扩展文件的URL?
如果用户已删除扩展文件,如何从Google Play获取扩展文件网址以下载文件。
解决方法
您必须使用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();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。