mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 05:37:43 +00:00
Make toast work from a background thread
Summary: When receiving a text share an attempt is made to show a toast but that results in an exception because the issuing thread is not running a looper. Test Plan: Without this patch applied Share a text with an android device using the plasmoid Result: No toast is displayed and in logcat you will get a: java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare() exception With this patch applied again Share a text an android device using the plasmoid Result: The toast is actually displayed even when the activity is not in the foreground Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D17400
This commit is contained in:
parent
ebbd47704a
commit
087b7ce875
@ -191,7 +191,7 @@ public class SharePlugin extends Plugin implements ReceiveFileRunnable.CallBack
|
||||
String text = np.getString("text");
|
||||
ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cm.setText(text);
|
||||
Toast.makeText(context, R.string.shareplugin_text_saved, Toast.LENGTH_LONG).show();
|
||||
handler.post(() -> Toast.makeText(context, R.string.shareplugin_text_saved, Toast.LENGTH_LONG).show());
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
Loading…
x
Reference in New Issue
Block a user