List of usage examples for android.app Activity runOnUiThread
public final void runOnUiThread(Runnable action)
From source file:Main.java
public static void toastShow(final Activity activity, final String message) { activity.runOnUiThread(new Runnable() { public void run() { Toast.makeText(activity, message, Toast.LENGTH_SHORT).show(); }//from w w w . ja v a 2 s. c om }); }
From source file:Main.java
/** * Shows an error alert dialog with the given message. * /* w ww . jav a 2 s . c om*/ * @param activity activity * @param message message to show or {@code null} for none */ public static void showError(final Activity activity, final String message) { activity.runOnUiThread(new Runnable() { public void run() { new AlertDialog.Builder(activity).setTitle("Error").setMessage(message).setNeutralButton("ok", null) .create().show(); } }); }
From source file:Main.java
public static void toastOnUI(final Activity activity, final String toastText, final int duration) { activity.runOnUiThread(new Runnable() { @Override/* www. j a va2 s .com*/ public void run() { Toast.makeText(activity, toastText, duration).show(); } }); }
From source file:Main.java
public static void showMsg(final Activity act, final String msg, final boolean isLongShow) { act.runOnUiThread(new Runnable() { @Override/*from w ww .j a v a2s.c o m*/ public void run() { // TODO Auto-generated method stub if (isLongShow) { Toast.makeText(act, msg, Toast.LENGTH_LONG).show(); } else { Toast.makeText(act, msg, Toast.LENGTH_SHORT).show(); } } }); }
From source file:Main.java
private static void showErrorInternal(final Activity activity, final String errorMessage) { activity.runOnUiThread(new Runnable() { public void run() { Toast.makeText(activity, errorMessage, Toast.LENGTH_LONG).show(); }//from w ww .ja v a 2s.co m }); }
From source file:Main.java
public static void showToastNotification(final String msg, final Activity activity) { if (activity == null) return;/*from w w w . j a va 2 s . c o m*/ activity.runOnUiThread(new Runnable() { public void run() { Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show(); } }); }
From source file:Main.java
public static void displayToast(final Activity activity, final String text, final int duration) { activity.runOnUiThread(new Runnable() { public void run() { Toast toast = Toast.makeText(activity, text, duration); toast.show();// w ww . ja v a2 s .co m } }); }
From source file:Main.java
public static void DisplayAlertOKCancel(final Context context, final String title, final String message) { retValue = -1;//from www. ja v a 2 s . c o m final Activity activity = (Activity) context; activity.runOnUiThread(new Runnable() { @Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message); builder.setTitle(title); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { retValue = 1; alert = null; } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { retValue = 0; alert = null; } }); alert = builder.create(); alert.show(); } }); }
From source file:Main.java
public static void invalidateOptionsMenu(final Activity a) { if (Build.VERSION.SDK_INT >= 11) { a.runOnUiThread(new Runnable() { @Override/* w w w . ja v a 2s .c o m*/ public void run() { a.invalidateOptionsMenu(); } }); } }
From source file:Main.java
public static void hideKeyBoard(final Activity activity) { if (activity == null) return;//from w w w . j a va 2s . co m activity.runOnUiThread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub InputMethodManager mgr = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0); } }); }