Get clipboard Text Length - Android Android OS

Android examples for Android OS:Clipboard

Description

Get clipboard Text Length

Demo Code


//package com.java2s;
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;
    }/*  ww w .j ava  2 s .  co m*/
}

Related Tutorials