Skip to content

Instantly share code, notes, and snippets.

@plateaukao
Created September 28, 2020 15:56
Show Gist options
  • Save plateaukao/a519855748f4360d13e03594c7cf7703 to your computer and use it in GitHub Desktop.
Save plateaukao/a519855748f4360d13e03594c7cf7703 to your computer and use it in GitHub Desktop.
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
// what the heck! 這件事做在 onResume() 中是沒有用的。害我試了好久
val clipBoardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val copiedString = clipBoardManager.primaryClip?.getItemAt(0)?.text?.toString() ?: ""
if (copiedString.isNotEmpty()) {
handleSendText(copiedString)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment