List of usage examples for android.widget Toast LENGTH_SHORT
int LENGTH_SHORT
To view the source code for android.widget Toast LENGTH_SHORT.
Click Source Link
From source file:Main.java
public static void sendSMS(String phoneNo, String message, Context context) { Log.i("Sending SMS to " + phoneNo, ""); try {//from w w w . j a va2 s. co m SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo, null, message, null, null); Toast.makeText(context, "SMS sent to " + phoneNo, Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(context, "SMS sending failed to " + phoneNo, Toast.LENGTH_SHORT).show(); e.printStackTrace(); } }
From source file:Main.java
public static Camera getCameraInstance(Context context) { Camera c = null;/*w w w.j a v a 2 s. c o m*/ try { if (checkCameraHardware(context)) { c = Camera.open(); } } catch (Exception e) { Toast.makeText(context, "Camera is not available", Toast.LENGTH_SHORT).show(); } return c; }
From source file:Main.java
public static void showToast(Context context, CharSequence text) { showToast(context, text, Toast.LENGTH_SHORT); }
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 showShortToast(Context context, CharSequence message) { if (context == null) return;// www .java 2s . com if (mToast == null) { mToast = getToastObj(context); } mToast.setText(message); mToast.setDuration(Toast.LENGTH_SHORT); mToast.show(); }
From source file:Main.java
/** * show Short Image Toast/*from w w w .ja va 2 s. c o m*/ * See{@link #showImageToast(Context, int, String, int)} * * @param context :context * @param ImageResId : imageres id * @param text : the msg you will show */ public static void showShortImageToast(Context context, int ImageResId, String text) { showImageToast(context, ImageResId, text, Toast.LENGTH_SHORT); }
From source file:Main.java
/** * Shows a {@link Toast} on the UI thread. * * @param text The message to show/* ww w .j av a 2 s . com*/ */ 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 void ToastMsg(Context context, String msg) { if (context == null || TextUtils.isEmpty(msg)) { return;// ww w .j a v a 2 s.co 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 showMsg(final Activity act, final String msg, final boolean isLongShow) { act.runOnUiThread(new Runnable() { @Override// w w w.j a v a 2 s . c om 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
public static void showShort(Context context, @StringRes int resId) { if (context != null) { Toast.makeText(context.getApplicationContext(), resId, Toast.LENGTH_SHORT).show(); }// w w w .j a v a 2 s . c o m }