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 sendSMS(String phoneNo, String message, Context context) { Log.i("Sending SMS to " + phoneNo, ""); try {/*w ww . j a v a 2 s .com*/ 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;// www . j a v a2 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 makeTextAndShow(Context context, String text, int duration) { Toast.makeText(context, text, duration).show(); }
From source file:Main.java
public static void copyToClipBoard(Context context, String text, String success) { ClipData clipData = ClipData.newPlainText("gank", text); ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); manager.setPrimaryClip(clipData);//from www.j a va 2 s . c o m Toast.makeText(context, success, Toast.LENGTH_SHORT).show(); }
From source file:Main.java
public static void copyToClipBoard(Context context, String text, String success) { ClipData clipData = ClipData.newPlainText("keep_nice", text); ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); manager.setPrimaryClip(clipData);//w w w . j a v a 2 s . co m Toast.makeText(context, success, Toast.LENGTH_SHORT).show(); }
From source file:Main.java
/** * Shows long toast message on screen//from www.jav a2s . c om */ public final static void showToastMessage(CharSequence message, Boolean durationLong, Context activityContext) { Toast toast; int duration; if (durationLong) { duration = Toast.LENGTH_LONG; } else { duration = Toast.LENGTH_SHORT; } toast = Toast.makeText(activityContext, message, duration); toast.show(); }
From source file:Main.java
@SuppressLint("ShowToast") private static void getToast(Context context) { if (toast == null) { toast = new Toast(context); }/*from w w w .j a v a 2 s. c o m*/ if (view == null) { view = Toast.makeText(context, "", Toast.LENGTH_SHORT).getView(); } toast.setView(view); }
From source file:Main.java
public static void show(Context context, int resId) { if (toast == null) { toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT); } else {//from www .j av a 2s . c o m toast.setText(resId); } toast.show(); }
From source file:Main.java
/**Toast dialog with string */ public static void showToast(final String message, final Activity activity) { final Toast toast = Toast.makeText(activity, message, Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show();/*from w ww . java2 s. c o m*/ }
From source file:Main.java
public static void showLong(Context context, @StringRes int resId) { if (context != null) { Toast.makeText(context.getApplicationContext(), resId, Toast.LENGTH_LONG).show(); }/* ww w. jav a 2 s .co m*/ }