我試圖安裝的擴展文件是這樣的:如何安裝加密的APK擴展文件?
final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
String obbPath = Environment.getExternalStorageDirectory() + "/Android/obb";
final String obbFilePath = obbPath + "/com.example/main.1.com.example.obb";
storageManager.mountObb(obbFilePath, "SecretKey", new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
if (state == OnObbStateChangeListener.MOUNTED) {
onObbMounted();
} else {
Log.d("##", "Path: " + path + "; state: " + state);
}
}
});
但在運行時我得到國家21:ERROR_COULD_NOT_MOUNT:
Path: /storage/sdcard0/Android/obb/com.example/main.1.com.example.obb; state: 21
我已經添加了這一點:
File f = new File(obbFilePath);
if (!f.exists()) {
Log.e("OBB", "FILE NOT FOUND!!!");
}
logcat說這個文件存在。我不知道,爲什麼我能得到這個狀態21?
那麼,我還沒有找到如何安裝加密的obb文件,但使用非加密的obb工作正常。 –
hello叔叔Lem,在這裏我面臨同樣的狀態-21,所以請給我一個例子我怎樣才能使用非加密的obb –
@KrunalShah我創建了util類來管理obb,請參閱https://github.com/uncleLem /AndroidUtils/blob/master/src/io/github/unclelem/androidutils/utils/ObbExpansionsManager.java你也可以在我的其他答案中找到一些細節:http://stackoverflow.com/questions/14685315/how-to-create -ob-files-using-jobb-tool-android/14687592#14687592 –