Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.ClipData; import android.content.ClipDescription; import android.content.ClipboardManager; import android.content.Context; import android.os.Build; public class Main { public static boolean hasText(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(); return clipData != null && description != null && (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)); } else { //noinspection deprecation return cm.hasText(); } } }