List of usage examples for android.widget Toast makeText
public static Toast makeText(Context context, @StringRes int resId, @Duration int duration) throws Resources.NotFoundException
From source file:Main.java
public static void showShort(Context context, @StringRes int resId) { if (context != null) { Toast.makeText(context.getApplicationContext(), resId, Toast.LENGTH_SHORT).show(); }//ww w.j a v a2 s . co m }
From source file:Main.java
private static Toast getToastObj(Context context) { return Toast.makeText(context, "", Toast.LENGTH_SHORT); }
From source file:Main.java
public static void ShowToast(Context cxt, String str, boolean isLong) { if (isLong) { Toast.makeText(cxt, str, Toast.LENGTH_LONG).show(); } else {// ww w . j a va 2 s .co m Toast.makeText(cxt, str, Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
private static void show(Context context, String message, int duration) { if (toast == null) { toast = Toast.makeText(context, message, duration); } else {// w w w. j ava2s . co m toast.setText(message); } toast.show(); }
From source file:Main.java
public static boolean instantExec(Context context, String command) { try {//from ww w .j a v a 2s . c o m runSuCommand(context, command.toString()); } catch (Exception e) { Toast.makeText(context, "E:ScriptRunner: " + e.getMessage(), Toast.LENGTH_SHORT).show(); Log.d(LOGTAG, "E:ScriptRunner: " + e.getMessage()); return false; } return true; }
From source file:Main.java
/** * Shows a {@link Toast} on the UI thread. * * @param text The message to show/* w w w .j ava 2 s. c o m*/ */ public static void showToast(final Fragment fragment, final String text) { if (fragment.getActivity() != null) { fragment.getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(fragment.getActivity(), text, Toast.LENGTH_SHORT).show(); } }); } }
From source file:Main.java
public static boolean isNetworkOk(Context context) { ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; } else {/* w ww .j ava 2s .co m*/ Toast.makeText(context, "Network is disconnected", Toast.LENGTH_SHORT).show(); return false; } }
From source file:Main.java
public static void ToastMsg(Context context, String msg) { if (context == null || TextUtils.isEmpty(msg)) { return;/*from ww w . j av a 2s . c o m*/ } if (mToast != null) { mToast.cancel(); mToast = null; } mToast = Toast.makeText(context, msg, Toast.LENGTH_SHORT); mToast.show(); }
From source file:Main.java
public static void toast(final String text) { Activity a = activity.get();/* www. j a v a 2s . com*/ if (a == null) { return; } a.runOnUiThread(new Runnable() { public void run() { Toast.makeText(context, text, Toast.LENGTH_LONG).show(); } }); }
From source file:Main.java
private static void installApk(Context context, Uri uri) { try {/* www . jav a2 s . c o m*/ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/vnd.android.package-archive"); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); Toast.makeText(context, "DanaCast is out-dated, please visit http://danacast.me/", Toast.LENGTH_LONG) .show(); } }