Skip to content

Commit 88aa011

Browse files
committed
修复系统 Toast 调用 setText 出现崩溃的问题
1 parent 6e6760c commit 88aa011

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

library/src/main/java/com/hjq/toast/SystemToast.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ public void setView(View view) {
4444
@Override
4545
public void setText(CharSequence text) {
4646
if (mMessageView == null) {
47-
// Github issue 地址:https://github.com/getActivity/Toaster/issues/160
48-
super.setText(text);
47+
try {
48+
super.setText(text);
49+
} catch (Exception e) {
50+
// Github issue 地址:https://github.com/getActivity/Toaster/issues/160
51+
// java.lang.RuntimeException: This Toast was not created with Toast.makeText()
52+
e.printStackTrace();
53+
}
4954
return;
5055
}
5156
mMessageView.setText(text);

0 commit comments

Comments
 (0)