diff --git a/android/phoenix/src/org/retroarch/browser/MainMenuActivity.java b/android/phoenix/src/org/retroarch/browser/MainMenuActivity.java index c5d4af23ec..b638bd7f02 100644 --- a/android/phoenix/src/org/retroarch/browser/MainMenuActivity.java +++ b/android/phoenix/src/org/retroarch/browser/MainMenuActivity.java @@ -24,6 +24,7 @@ import android.widget.Toast; public final class MainMenuActivity extends PreferenceActivity { private static MainMenuActivity instance = null; private static final int ACTIVITY_LOAD_ROM = 0; + private static final int ACTIVITY_RETROARCH = 1; private static final String TAG = "MainMenu"; private static String libretro_path; private static String libretro_name; @@ -333,11 +334,18 @@ public final class MainMenuActivity extends PreferenceActivity { myIntent.putExtra("LIBRETRO", libretro_path); myIntent.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(this)); myIntent.putExtra("IME", current_ime); - startActivity(myIntent); + startActivityForResult(myIntent, ACTIVITY_RETROARCH); } - } break; } + + case ACTIVITY_RETROARCH: { + Log.i(TAG, "RetroArch finished running."); + UserPreferences.readbackConfigFile(this); + break; + } + + } } @Override diff --git a/android/phoenix/src/org/retroarch/browser/RetroTVMode.java b/android/phoenix/src/org/retroarch/browser/RetroTVMode.java index cd3bedd016..0f29c78b7a 100644 --- a/android/phoenix/src/org/retroarch/browser/RetroTVMode.java +++ b/android/phoenix/src/org/retroarch/browser/RetroTVMode.java @@ -6,22 +6,48 @@ import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.provider.Settings; +import android.util.Log; public final class RetroTVMode extends Activity { + private static final String TAG = "RetroTVMode"; + private static final int ACTIVITY_RETROARCH = 1; + // Need to do this wonky logic as we have to keep this activity alive until + // RetroArch is done running. + // Have to readback config right after RetroArch has run to avoid potential + // broken config state. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - UserPreferences.updateConfigFile(this); + if (savedInstanceState == null + || !savedInstanceState.getBoolean("started", false)) { + UserPreferences.updateConfigFile(this); - Intent myIntent = new Intent(this, RetroActivity.class); - String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); - myIntent.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(this)); - myIntent.putExtra("IME", current_ime); - startActivity(myIntent); - finish(); + Intent myIntent = new Intent(this, RetroActivity.class); + String current_ime = Settings.Secure.getString( + getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); + myIntent.putExtra("CONFIGFILE", + UserPreferences.getDefaultConfigPath(this)); + myIntent.putExtra("IME", current_ime); + startActivityForResult(myIntent, ACTIVITY_RETROARCH); + } + } + + @Override + protected void onActivityResult(int reqCode, int resCode, Intent data) { + switch (reqCode) { + case ACTIVITY_RETROARCH: { + Log.i(TAG, "RetroArch finished running."); + UserPreferences.readbackConfigFile(this); + finish(); + break; + } + } + } + + @Override + protected void onSaveInstanceState(Bundle savedInstanceState) { + savedInstanceState.putBoolean("started", true); } } - -