在使用系统的
在使用系统提供的Toast类的时候,出现过报错,崩了的情况.
Toast.makeText(context, resId, Toast.LENGTH_SHORT).show();
后来用了一个自定义的ToastUtils,就避免了一些 错误 情况.
package com.baidu.idl.main.facesdk.registerlibrary.user.utils;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;
public class ToastUtils {
private static Handler handler = new Handler(Looper.getMainLooper());
public static void toast(final Context context, final String text) {
handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}