From 56975f8ee0bcfa4ebbf4be15ba4ed67314e22d1d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 7 Aug 2013 03:33:58 +0200 Subject: [PATCH] Add showToastAlert from Tegra Subactivity --- .../org/retroarch/browser/RetroActivity.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/android/phoenix/src/org/retroarch/browser/RetroActivity.java b/android/phoenix/src/org/retroarch/browser/RetroActivity.java index 38a3fb1cbd..8a666d8e5c 100644 --- a/android/phoenix/src/org/retroarch/browser/RetroActivity.java +++ b/android/phoenix/src/org/retroarch/browser/RetroActivity.java @@ -2,6 +2,7 @@ package org.retroarch.browser; import android.app.NativeActivity; import android.os.Bundle; +import android.widget.Toast; public class RetroActivity extends NativeActivity { public RetroActivity() { @@ -20,4 +21,20 @@ public class RetroActivity extends NativeActivity { @Override public void onTrimMemory(int level) { } + + // We call this function from native to display a toast string + public void showToastAlert(String text) + { + // We need to use a runnable here to ensure that when the spawned + // native_app_glue thread calls, we actually post the work to the UI + // thread. Otherwise, we'll likely get exceptions because there's no + // prepared Looper on the native_app_glue main thread. + final String finalText = text; + runOnUiThread(new Runnable() { + public void run() + { + Toast.makeText(getApplicationContext(), finalText, Toast.LENGTH_SHORT).show(); + } + }); + } }