Java tutorial
//package com.java2s; //License from project: Open Source License import android.annotation.SuppressLint; import android.content.ClipboardManager; import android.content.Context; import android.os.Build; public class Main { private static android.text.ClipboardManager oldClipboard = null; private static ClipboardManager clipboard = null; /** * Return true if there is text in the clipboard * @param ctx * @return */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") public static boolean checkForText(Context ctx) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (clipboard == null) { clipboard = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE); } return clipboard.hasPrimaryClip(); } else { if (oldClipboard == null) { oldClipboard = (android.text.ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE); } return oldClipboard.hasText(); } } }