public static void set(Context context, String text) { if (!VipApplication.getInstance().lockLooper) { Looper.prepare(); VipApplication.getInstance().lockLooper = true; } ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); cmb.setText(text); Log.v("DEV", "Clipboard set:" + text); }
public static String get(Context context) { if (!VipApplication.getInstance().lockLooper) { Looper.prepare(); VipApplication.getInstance().lockLooper = true; } ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); String data; if (cmb.getText() == null) { data = ""; } else { data = cmb.getText().toString(); } return data; }