Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Map; import android.annotation.SuppressLint; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.os.Build; public class Main { /** * Copy tags to clipboard as multi-line text in the form * key1=value1 * key2=value2 * ..... * @param tags */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") public static void copyTags(Context ctx, Map<String, String> tags) { StringBuffer tagsAsText = new StringBuffer(); for (String key : tags.keySet()) { tagsAsText.append(key + "=" + tags.get(key) + "\n"); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ClipboardManager clipboard = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("OSM Tags", tagsAsText.toString()); clipboard.setPrimaryClip(clip); } else { android.text.ClipboardManager oldClipboard = (android.text.ClipboardManager) ctx .getSystemService(Context.CLIPBOARD_SERVICE); oldClipboard.setText(tagsAsText.toString()); } } }