Code example for ClipboardManager

Methods: setPrimaryClip

0
     * @param text The text to copy. 
     * @param toastMessage The message to show in a Toast notification. If empty or null, does not display notification. 
     */ 
    public static void copyTextToClipboard(Context context, String text, String toastMessage) {
    	ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
    	clipboard.setPrimaryClip(ClipData.newPlainText(text, text));
    	 
    	if ((toastMessage != null) &&
    			(toastMessage.length() > 0)) {
    		Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show();
    	} 
    } 
	 
	/** 
	 * Display a standard yes / no dialog. 
	 * @param context The current context. 
	 * @param icon The dialog icon. 
	 * @param title The dialog title. 
	 * @param message The dialog message. 
	 * @param onYes The dialog listener for the yes button. 
	 */