Mathias Conradt
Mathias Conradt

Reputation: 28665

Mounting obb file on Galaxy Tab / Android 4.1.2 not working; working fine with Android 4.4.4

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);            
        }
    }); 

Upvotes: 1

Views: 886

Answers (2)

MacD
MacD

Reputation: 863

I've run across this problem myself on some devices; this could also be due to a bug in android:

https://code.google.com/p/android/issues/detail?id=61881

It seems that the only thing to do is start using AssetFileDescriptors and offsets (for audio/video) or inputstreams. In my case I can't use any of these as I need a String/filepath, so I think I'm going to be forced to unzip the expansion file somewhere.

Upvotes: 1

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.

Upvotes: 1

Related Questions