Android Utililty Methods Toast Create

List of utility methods to do Toast Create

Description

The list of methods to do Toast Create are organized into topic(s).

Method

voidtoast(String message, Context context)
toast
Toast msg = Toast.makeText(context, message, Toast.LENGTH_LONG);
msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2,
        msg.getYOffset() / 2);
msg.show();
voidtoast(final Context context, final CharSequence msg)
toast
new Handler(Looper.getMainLooper()).post(new Runnable() {
    @Override
    public void run() {
        Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
});
voidmsgLong(Context context, String msg)
Long toast message
if (context != null && msg != null) {
    Toast.makeText(context, msg.trim(), Toast.LENGTH_LONG).show();
voidmsgLong(final Context c, final String msg)
Long toast message
if (c != null && msg != null) {
    Toast.makeText(c, msg.trim(), Toast.LENGTH_LONG).show();
voidmsgLong(final Context context, final String msg)
Long toast message (Predefined in AOS to 3500 ms = 3.5 sec)
if (context != null && msg != null) {
    new Handler(context.getMainLooper()).post(new Runnable() {
        @Override
        public void run() {
            Toast.makeText(context, msg.trim(), Toast.LENGTH_LONG)
                    .show();
    });
...
voidmsgShort(Context context, String msg)
Short toast message
if (context != null && msg != null) {
    Toast.makeText(context, msg.trim(), Toast.LENGTH_SHORT).show();
voidmakeToast(Context appContext, String valueToShow)
make Toast
Toast.makeText(appContext, valueToShow, Toast.LENGTH_LONG).show();
voidmakeToast(Context context, String message, boolean longTime)
make Toast
if (longTime) {
    Toast.makeText(context, message, Toast.LENGTH_LONG).show();
} else {
    Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
voidsendMsg(Context context, String msg)
Long toast message
if (context != null && msg != null) {
    msgLong(context, msg);
voidsendMsg(Context context, String msg)
Long toast message
if (context != null && msg != null) {
    msgLong(context, msg);