forked from Kolyah35/minecraft-pe-0.6.1
FIXED: Saving works on Android now!
I honestly changed too much stuff trying to pinpoint a fix. I might be stupid. I have no idea what I did that fixed this.
This commit is contained in:
@@ -30,12 +30,33 @@ static void setupExternalPath(JNIEnv* env, MAIN_CLASS* app)
|
||||
{
|
||||
LOGI("Environment exists");
|
||||
}
|
||||
jclass clazz = env->FindClass("android/os/Environment");
|
||||
jmethodID method = env->GetStaticMethodID(clazz, "getExternalStorageDirectory", "()Ljava/io/File;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
// try appspecific external directory first
|
||||
jobject activity = g_pActivity;
|
||||
jclass activityClass = env->GetObjectClass(activity);
|
||||
jmethodID getExternalFilesDir = env->GetMethodID(activityClass, "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;");
|
||||
|
||||
jobject file = NULL;
|
||||
if (getExternalFilesDir != NULL) {
|
||||
file = env->CallObjectMethod(activity, getExternalFilesDir, NULL);
|
||||
}
|
||||
|
||||
if (file == NULL) {
|
||||
// Fallback to the legacy shared storage directory
|
||||
jclass clazz = env->FindClass("android/os/Environment");
|
||||
jmethodID method = env->GetStaticMethodID(clazz, "getExternalStorageDirectory", "()Ljava/io/File;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
}
|
||||
file = env->CallStaticObjectMethod(clazz, method);
|
||||
}
|
||||
|
||||
if (!file) {
|
||||
LOGI("Failed to get external storage file object, using current working dir");
|
||||
app->externalStoragePath = ".";
|
||||
app->externalCacheStoragePath = ".";
|
||||
return;
|
||||
}
|
||||
jobject file = env->CallStaticObjectMethod(clazz, method);
|
||||
|
||||
jclass fileClass = env->GetObjectClass(file);
|
||||
jmethodID fileMethod = env->GetMethodID(fileClass, "getAbsolutePath", "()Ljava/lang/String;");
|
||||
@@ -43,7 +64,7 @@ static void setupExternalPath(JNIEnv* env, MAIN_CLASS* app)
|
||||
|
||||
const char* str = env->GetStringUTFChars((jstring) pathString, NULL);
|
||||
app->externalStoragePath = str;
|
||||
app->externalCacheStoragePath = str;
|
||||
app->externalCacheStoragePath = str;
|
||||
LOGI("%s", str);
|
||||
|
||||
// same fix as the native entry point: make sure cwd is writable
|
||||
|
||||
Reference in New Issue
Block a user