Toast疯狂点击闪退问题

  • 内容
  • 相关

在使用Toast.show时,疯狂点击测试中,出现如下错误。

errLog

错误信息:

A/OpenGLRenderer: Failed to set damage region on surface 0x8f8849c8, error=EGL_BAD_ACCESS
W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
W/google-breakpad: Chrome build fingerprint:
    V0.1.0
    238445
    ### ### ### ### ### ### ### ### ### ### ### ### ###
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 4125 (RenderThread), pid 4086 (gps.landleveler)

 

原因;不能不停的去实例Toast。可以使用setText,也可以使用其他toast

解决方法:

使用线程解决


public static
ToastHelper Inst() {
if (inst == null) {
inst = new ToastHelper();
}

return inst;
}

private void Post(Runnable task) {
handler.post(task);
}

private void showToast(final String text) {
Post(new Runnable(){
@Override
public void run() {
if (toast == null) {
toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
} else {
toast.setText(text);
}
toast.show();
}
});
}

public static void showToast(String text) { Inst().showToast(text); }

public static void post(Runnable task) { Inst().Post(task); }

使用ToastHelper.showToast(content);

 

管理员设置 回复 可见隐藏内容

本文标签:

版权声明:若无特殊注明,本文皆为《admin_H》原创,转载请保留文章出处。

本文链接:Toast疯狂点击闪退问题 - https://blog.bnist.com/post/5

发表评论

电子邮件地址不会被公开。 必填项已用*标注

未显示?请点击刷新

允许邮件通知
Sitemap