Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;

public class Main {
    private static String getClipText(Context context) {
        String text = "";
        ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clipData = cm.getPrimaryClip();
        if (clipData != null) {
            if (clipData.getItemCount() > 0) {
                ClipData.Item item = clipData.getItemAt(0);
                text = item.getText().toString();
            }
        }

        return text;
    }
}