android 获取剪切板内容

val cm = activity!!.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
if (cm != null && cm.primaryClip != null) {
var clipData: ClipData = cm.primaryClip!!
if (clipData != null) {
//获取 text
var text: String = clipData.getItemAt(0).coerceToText(context).toString()

你可能感兴趣的:(android 获取剪切板内容)