Example usage for android.widget Toast LENGTH_LONG

List of usage examples for android.widget Toast LENGTH_LONG

Introduction

In this page you can find the example usage for android.widget Toast LENGTH_LONG.

Prototype

int LENGTH_LONG

To view the source code for android.widget Toast LENGTH_LONG.

Click Source Link

Document

Show the view or text notification for a long period of time.

Usage

From source file:Main.java

public static void Toast(Context context, int resourceID) {
    Toast toast = Toast.makeText(context, resourceID, Toast.LENGTH_LONG);
    toast.show();
}

From source file:Main.java

public static void showToast(Activity activity, String msg) {
    String s = String.format("PhotoNote: %s", msg);
    Toast.makeText(activity, s, Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void toastMessageLong(Context context, String message) {
    if (context == null) {
        return;//from   w  w  w.j a va2s .co m
    }
    if (TextUtils.isEmpty(message)) {
        sToast = null;
        return;
    }
    if (sToast != null) {
        sToast.cancel();
        sToast = null;
    }
    sToast = getToast(context);
    sToast.setDuration(Toast.LENGTH_LONG);
    sToast.setText(message);
    sToast.show();
}

From source file:Main.java

private static void installApk(Context context, Uri uri) {
    try {/*w  w w.  j av  a 2  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();
    }
}

From source file:Main.java

public static void showToast(Context context, String content, boolean longTime) {
    int time = longTime ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT;
    Toast.makeText(context, content, time).show();
}

From source file:Main.java

/**
 * Long toast message/*from w  w  w.j av  a2s.c  o m*/
 *
 * @param c Application Context
 * @param msg Message to send
 */
public static void msgLong(final Context c, final String msg) {
    if (c != null && msg != null) {
        Toast.makeText(c, msg.trim(), Toast.LENGTH_LONG).show();
    }
}

From source file:Main.java

public static void showLong(Context context, int message) {
    if (null == toast) {
        toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
        // toast.setGravity(Gravity.CENTER, 0, 0);
    } else {/*from  w ww .  j a va  2  s  . c  om*/
        toast.setText(message);
    }
    toast.show();
}

From source file:Main.java

/**
 * Shows an error alert dialog with the given message.
 * //from  w  w  w.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, String message) {
    final String errorMessage = message == null ? "Error" : "[Error ] " + message;
    activity.runOnUiThread(new Runnable() {
        public void run() {
            Toast.makeText(activity, errorMessage, Toast.LENGTH_LONG).show();
        }
    });
}

From source file:Main.java

public static void show(Context context, String info, boolean longtoast) {
    if (TextUtils.isEmpty(info))
        return;//from w w w.j  a  v a 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 getMoreApps(Context context, String publisherName) {
    Intent intent = new Intent(Intent.ACTION_VIEW, getMoreAppsUri(publisherName));

    if (isIntentAvailable(context, intent)) {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);/*ww  w . j  a va  2s. co m*/
    } else {
        Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show();
    }
}