Ktolin code to get the Clipbaord text on Android

val manager: ClipboardManager = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager

if (manager.hasPrimaryClip() && manager.primaryClip?.itemCount!! > 0) {
    val addedText: CharSequence = manager.primaryClip!!.getItemAt(0).text
    val addedTextString = addedText.toString()
    if (!TextUtils.isEmpty(addedTextString)) {
        println("addedTextString: $addedTextString")
    }
}