Skip to content

Commit 37a32f8

Browse files
committed
Toast now runs on UI thread
1 parent f083331 commit 37a32f8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

wear-socket/src/main/java/com/github/jrejaud/wear_socket/WearSocket.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ public void run() {
103103
String nodeID = findBestNodeId(nodes);
104104
Log.d(TAG,"Node found: "+nodeID);
105105
if (nodeID==null) {
106-
String message = "Error, cannot find a connected device";
107-
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
106+
final String message = "Error, cannot find a connected device";
107+
((Activity)context).runOnUiThread(new Runnable() {
108+
@Override
109+
public void run() {
110+
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
111+
}
112+
});
108113
new Throwable(message);
109114
return;
110115
}

0 commit comments

Comments
 (0)