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 startDialer(Context context, String phoneNumber) { try {//www.j a va 2 s .c om Intent dial = new Intent(); dial.setAction(Intent.ACTION_DIAL); dial.setData(Uri.parse("tel:" + phoneNumber)); context.startActivity(dial); } catch (Exception ex) { Log.e(TAG, "Error starting phone dialer intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app to place a phone call!", Toast.LENGTH_SHORT) .show(); } }
From source file:Main.java
/** * Function use through the app to show Toast information. Function is called so often from * background, that it's content is explicitly called from UIThread. * * @param appContext - application context * @param stringResourceId of text we show * @param handler to UIThread/*from www . j a va 2 s . c o m*/ */ public static void showToast(final Context appContext, final int stringResourceId, Handler handler) { handler.post(new Runnable() { @Override public void run() { Toast.makeText(appContext, appContext.getString(stringResourceId), Toast.LENGTH_SHORT).show(); } }); }
From source file:Main.java
/** * Open the google play store market with this app * /* www .j av a2 s . c o m*/ * @param context the application context */ public static void openMarket(Context context) { Uri uri = Uri.parse("market://details?id=" + context.getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); try { context.startActivity(goToMarket); } catch (ActivityNotFoundException e) { Toast.makeText(context, "Couldn't launch the market", Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static void show(Context context, String info, boolean longtoast) { if (TextUtils.isEmpty(info)) return;// w ww. java 2 s .c om if (longtoast) { Toast.makeText(context, info, Toast.LENGTH_LONG).show(); } else { Toast.makeText(context, info, Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static void startEmailIntent(Context context, String emailAddress) { try {/*w w w .ja v a2 s .c o m*/ Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { emailAddress }); context.startActivity(intent); } catch (Exception ex) { Log.e(TAG, "Error starting email intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app for sending emails!", Toast.LENGTH_SHORT) .show(); } }
From source file:Main.java
/** * @param context The context the toast is displayed. Can be application context. * @param text The text contained in the toast * @param shortTime Whether to display toast with shorter duration. *//*from ww w . j av a 2 s . com*/ public static void createToast(Context context, String text, boolean shortTime) { int duration = (shortTime) ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG; Toast.makeText(context, text, duration).show(); }
From source file:Main.java
/** * Copy a text to the clipboard.// www . j a v a 2 s . c o m * @param context * @param text * @param toastMessage The message to show in a Toast notification. If empty or null, does not display notification. */ public static void copyTextToClipboard(Context context, String text, String toastMessage) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); clipboard.setText(text); if (toastMessage != null && toastMessage.length() > 0) { Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static void showToastShort(Context ctx, String msg) { Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show(); }
From source file:Main.java
/** * Function use through the app to show Toast information and finish current activity. * Function is called so often from background, that it's content is explicitly called from UIThread. * * @param activity - is current activity to finish * @param stringResourceId of text we show * @param handler to UIThread/*from ww w. j a v a2 s . c om*/ */ public static void showToastAndFinishActivity(final Activity activity, final int stringResourceId, Handler handler) { handler.post(new Runnable() { @Override public void run() { Toast.makeText(activity, activity.getString(stringResourceId), Toast.LENGTH_SHORT).show(); activity.finish(); } }); }
From source file:Main.java
public static void startSmsIntent(Context context, String phoneNumber) { try {//from w ww. j a va 2s . co m Uri uri = Uri.parse("sms:" + phoneNumber); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.putExtra("address", phoneNumber); intent.setType("vnd.android-dir/mms-sms"); context.startActivity(intent); } catch (Exception ex) { Log.e(TAG, "Error starting sms intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app to send an SMS!", Toast.LENGTH_SHORT).show(); } }