List of usage examples for android.content ClipboardManager getText
@Deprecated
public CharSequence getText()
From source file:Main.java
public static String paste(Context context) { ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); return cmb.getText().toString(); }
From source file:Main.java
public static String paste(Context context) { ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); return cmb.getText().toString().trim(); }
From source file:Main.java
public static String paste(Context context) { ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); String content = cmb.getText().toString().trim(); return content; }
From source file:Main.java
public static void getLatestTextSupport(Context context) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.getText(); }
From source file:Main.java
public static String pasteString(Context context) { int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); return clipboard.getText().toString().trim(); } else {// w ww. ja v a 2s . c om android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); return clipboard.getText().toString(); } }
From source file:Main.java
/** * This is only called when we are on API level < Honeycomb * @param context The context, required to get the Cliboard System Service. * @return Returns the latest text copied to the clipboard by the user *///www . j av a 2 s . c o m @SuppressWarnings("deprecation") private static String getTextFromClipboard(final Context context) { android.text.ClipboardManager manager = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); String text = (String) manager.getText(); //Yep, that much simpler. if (text == null) text = EMPTY_STRING; return text; }
From source file:Main.java
@SuppressWarnings("deprecation") public static String getText(Context context) { ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipData clipData = clipboardManager.getPrimaryClip(); if (hasText(clipboardManager, clipData)) { return clipData.getItemAt(0).getText().toString(); } else {/* w ww.j ava2 s . co m*/ return null; } } else { return clipboardManager.getText().toString(); } }
From source file:Main.java
public static CharSequence getText(Context context) { ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipDescription description = cm.getPrimaryClipDescription(); ClipData clipData = cm.getPrimaryClip(); if (clipData != null && description != null && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { return clipData.getItemAt(0).getText(); } else {//from w w w. j ava 2 s. c o m return ""; } } else { //noinspection deprecation return cm.getText(); } }
From source file:de.syss.MifareClassicTool.Common.java
/** * Get the content of the Android clipboard (if it is plain text). * @param context Context of the SystemService * @return The content of the Android clipboard. On error * (clipboard empty, clipboard content not plain text, etc.) null will * be returned./*from w ww .j a va2 s . c o m*/ */ @SuppressLint("NewApi") @SuppressWarnings("deprecation") public static String getFromClipboard(Context context) { if (Build.VERSION.SDK_INT >= 11) { // Android API level 11+. android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard.getPrimaryClip() != null && clipboard.getPrimaryClip().getItemCount() > 0 && clipboard .getPrimaryClipDescription().hasMimeType(android.content.ClipDescription.MIMETYPE_TEXT_PLAIN)) { return clipboard.getPrimaryClip().getItemAt(0).getText().toString(); } } else { // Android API level 10. android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context .getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard.hasText()) { return clipboard.getText().toString(); } } // Error. return null; }
From source file:com.codename1.impl.android.AndroidImplementation.java
/** * @inheritDoc/*from w ww .ja v a 2 s .c o m*/ */ public Object getPasteDataFromClipboard() { if (getContext() == null) { return null; } final Object[] response = new Object[1]; runOnUiThreadAndBlock(new Runnable() { @Override public void run() { int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < 11) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); response[0] = clipboard.getText().toString(); } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0); response[0] = item.getText(); } } }); return response[0]; }