gpt4 book ai didi

android - 如何挂载加密的APK扩展文件?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:57:30 24 4
gpt4 key购买 nike

我试过这样挂载扩展文件:

    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?

最佳答案

我遇到了同样的问题,我发现很多次 Error 21 都是由 Linux Files Permissions over the obb 引起的,问题是 Android 无法访问它,所以 StorageManager 启动 错误 21。创建 .obb 文件时,更改文件的权限和用户组,例如:

$chmod 664 <obb-filename>.obb    
$chown user:group <obb-filename>.obb

然后再试一次,对我有用。

关于android - 如何挂载加密的APK扩展文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14342068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com