I try to mount an (unencrypted) obb file (APK expansion file).
The following code is working fine on Nexus 4 with Android 4.4.4. The obb file gets mounted and the OnObbStateChangeListener is entered as well, I can see the log lines in the log.
However, on Samsung Galax Tab 2 (with Android 4.1.2) it does not work. "Start mounting" is being logged, but then OnObbStateChangeListener is never entered, but also, no error or any other related info is shown in the log.
final StorageManager sm = (StorageManager) getApplicationContext().getSystemService(STORAGE_SERVICE);
Log.d(TAG, "Start mounting " );
sm.mountObb(
new File(Environment.getExternalStorageDirectory(),"Android/obb/com.matheapp.www.matheapp2/main.2.com.matheapp.www.matheapp2.obb").getAbsolutePath(),
new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
Log.d(TAG, "onObbStateChange: Path: " + path);
Log.d(TAG, "onObbStateChange: State: " + state);
}
});
We've been working in this and we didn't find any solution, so instead we are using a zip file renamed to .obb instead of a normal obb created with jobb
. That solution works in every device we've tested so far, even in the Galaxy Tab with Android 4.1.2
Hopes this works on your app also.