Get clipboard Text Length - Android android.content

Android examples for android.content:Clipboard

Description

Get clipboard Text Length

Demo Code

import android.content.Context;
import android.text.ClipboardManager;

public class Main{

    public static final int clipboardTextLength(Context context) {
        ClipboardManager cm = (ClipboardManager) context
                .getSystemService(Context.CLIPBOARD_SERVICE);
        CharSequence text = cm != null ? cm.getText() : null;
        return text != null ? text.length() : 0;
    }//w w  w  . ja  v a2 s.c om

}

Related Tutorials