public class KToast {
private static Toast toast;
private static Toast getInstance(Context context, CharSequence msg) {
if (toast == null) {
synchronized (KToast.class) {
if (toast == null) {
toast = Toast.makeText(context.getApplicationContext(), "", Toast.LENGTH_SHORT);
}
}
}
toast.setText(msg);
return toast;
}
/**
* 普通消息展示或系统自定义消息展示
* Toast.LENGTH_SHORT
*/
public static void showInfo(Context context, String msg) {
if (!UtilsStr.isEmpty(msg)) {
getInstance(context, msg).show();
}
}
}