Using:ToastUtils.LONG.show(context, R.string.greeting);Code:public class ToastUtils {    public static ToastUtils LONG = new ToastUtils(Toast.LENGTH_LONG);    public static ToastUtils SHORT = new ToastUtils(Toast.LENGTH_SHORT);    private final int duration;    private ToastUtils(int duration) {        this.duration = duration;    }    public Toast makeText(Context context, String text) {        return Toast.makeText(context, text, duration);    }    public void show(Context context, String text) {        makeText(context, text).show();    }    public Toast makeText(Context context, int resId) {        return Toast.makeText(context, resId, duration);    }    public void show(Context context, int resId) {        makeText(context, resId).show();    }}In my opinion, there are some disadvantages of using Toast class directly:In Toast class I often miss the call to show()Parameter length has type int. So a compiler couldn't detect invalid argument valueWhat do you think? Maybe this class is useless?Can you suggest any improvements?
ToastUtils - helper class for Android SDK Toast
java;android
There is one important thing missing on your LONG and SHORT fields.What if I do ToastUtils.LONG = null; ?That's right, I would break it.You must specify them as finalpublic class ToastUtils {    public static final ToastUtils LONG = new ToastUtils(Toast.LENGTH_LONG);    public static final ToastUtils SHORT = new ToastUtils(Toast.LENGTH_SHORT);However, you might just as well change this one and make it an enumpublic enum ToastUtils {    LONG(Toast.LENGTH_LONG), SHORT(Toast.LENGTH_SHORT);    ... // the rest of your code can look the sameBut I have to agree with @Kao that your class does not seem to be very useful.It is better to learn the existing API than creating your own API to avoid having to learn the existing API (Yes, I just made that up. It makes sense though, doesn't it?)