package com.mydemo.test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Set;
import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.storage.OnObbStateChangeListener;
import android.os.storage.StorageManager;
import android.view.KeyEvent;
import android.content.res.Configuration;
import android.widget.Toast;
import android.util.Log;
import android.view.WindowManager;
import android.provider.Settings.System;
public class MainActivity extends UnityPlayerActivity {
//这些东西都是与google obb有关的
//拷贝到项目主Activity中
/* google obb */
public String UnityGetObbPath() {
String obbPath = getObbDir().getPath();
// Log.v("debug",obbPath);
return obbPath;
}
public String UnityGetAbsoluteObbPath() {
String absobbPath = getObbDir().getAbsolutePath();
// Log.v("debug","Abs ObbPath is ");
// Log.v("debug",absobbPath);
return absobbPath;
}
public String UnityGetMountedPath(String rawPath) {
final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
String mountedObbPath = storageManager.getMountedObbPath(rawPath);
return mountedObbPath;
}
public boolean UnityMountObb(String rawPath) {
final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
boolean isAddToQueue = storageManager.mountObb(rawPath, null,
new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
switch (state) {
case ERROR_ALREADY_MOUNTED:
Log.v("Unity", "The OBB has already been mounted");
case ERROR_COULD_NOT_MOUNT:
Log.v("Unity",
"The OBB could not be mounted by the system");
break;
case ERROR_COULD_NOT_UNMOUNT:
Log.v("Unity", "The OBB could not be unmounted");
break;
case ERROR_INTERNAL:
Log.v("Unity",
"There was an internal system error encountered while trying to mount the OBB");
break;
case ERROR_NOT_MOUNTED:
Log.v("Unity",
"A call was made to unmount the OBB when it was not mounted");
break;
case ERROR_PERMISSION_DENIED:
Log.v("Unity",
"The current application does not have permission to use this OBB");
break;
case MOUNTED:
Log.v("Unity",
"The OBB container is now mounted and ready for use");
break;
case UNMOUNTED:
Log.v("Unity",
"The OBB container is now unmounted and not usable.");
break;
default:
break;
}
}
});
return isAddToQueue;
}
public boolean isUnityPathMount(String rawPath) {
final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
return storageManager.isObbMounted(rawPath);
}
}
unity android obb
4星 · 超过85%的资源 需积分: 10 148 浏览量
2016-04-28
10:24:04
上传
评论
收藏 3KB RAR 举报
年华2008
- 粉丝: 61
- 资源: 24
- 1
- 2
前往页