mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-07-03 21:21:12 +08:00
Handle possible exception in copyToClipboard
Some bugged devices throw a RuntimeException in setPrimaryClip
This commit is contained in:
parent
d1e8407764
commit
52ecd91055
@ -847,11 +847,16 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static void copyToClipboard(Context ctx, String contents) {
|
||||
ClipboardManager clipboard = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText(ctx.getString(R.string.stats), contents);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
try {
|
||||
ClipboardManager clipboard = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText(ctx.getString(R.string.stats), contents);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Utils.showToast(ctx, R.string.copied);
|
||||
Utils.showToast(ctx, R.string.copied);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "copyToClipboard failed: " + e.getMessage());
|
||||
Utils.showToastLong(ctx, R.string.error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void shareText(Context ctx, String subject, String contents) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user