在Galaxy Tab/Android 4.1.2上安装obb文件不工作;安卓4.4.4运行良好

在Galaxy Tab/Android 4.1.2上安装obb文件不工作;安卓4.4.4运行良好,android,galaxy-tab,apk-expansion-files,Android,Galaxy Tab,Apk Expansion Files,我尝试挂载一个(未加密的)obb文件(APK扩展文件) 下面的代码在使用安卓4.4.4的Nexus4上运行良好。 obb文件被挂载,OnobStateChangeListener也被输入,我可以在日志中看到日志行 final StorageManager sm = (StorageManager) getApplicationContext().getSystemService(STORAGE_SERVICE); Log.d(TAG, "Start mounting " ); sm.moun

我尝试挂载一个(未加密的)obb文件(APK扩展文件)

下面的代码在使用安卓4.4.4的Nexus4上运行良好。 obb文件被挂载,OnobStateChangeListener也被输入,我可以在日志中看到日志行

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);            
        }
    }); 
但是,在三星Galax Tab 2(Android 4.1.2)上,不起作用。正在记录“开始装载”,但从未输入OnobStateChangeListener,而且日志中未显示任何错误或任何其他相关信息

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

我们一直在研究这个问题,但没有找到任何解决方案,因此我们使用一个重命名为.obb的zip文件,而不是使用
jobb
创建的普通obb。到目前为止,该解决方案适用于我们测试过的所有设备,甚至适用于Android 4.1.2的Galaxy标签


希望这在你的应用程序上也能起作用。

我自己在一些设备上遇到过这个问题;这也可能是由于android中的一个bug造成的:


似乎唯一要做的就是开始使用AssetFileDescriptor和偏移量(用于音频/视频)或inputstreams。在我的例子中,我不能使用任何一个,因为我需要一个字符串/文件路径,所以我想我将被迫将扩展文件解压缩到某个地方。

我已经看到了这个问题,但适用于Android 4.4,而不是4.1.2。您也可以在不解压缩任何内容的情况下读取.zip文件,只需使用未压缩的zip文件并读取数据即可