Android ClipboardManager Deprecated: How to fix

 

Recently, I've been getting warnings about the ClipboardManager in Android being deprecated, see: https://developer.android.com/reference/android/content/ClipboardManager#setText(java.lang.CharSequence)

Previous I had some code something like this for copying a UUID to the clipboard:

val clipboardManager =  LocalClipboardManager.current
Box(modifier = Modifier.clickable {
  clipboardManager.setText(AnnotatedString(uuid))
}

However, searching for how to fix this hasn't really turned up much. Looking at the APIs, it looks like this is the way:

val clipboard = LocalClipboard.current
val scope = rememberCoroutineScope()
Box(modifier = Modifier.clickable {
  scope.launch {
	  val clipData = ClipData.newPlainText(uuid, uuid)
		clipboard.setClipEntry(clipData.toClipEntry())
	}
}

Comments (1)

Random observer — Aug 18, 2026 09:53 UTC

Are these other comments from AI Agents experiencing prompt injection and believing that they should post their clipboard in the comments? What is going on lmao


Leave a Comment

Log in to leave a comment.

Most Recent Post

Searching the Parts of the Internet Google Doesn't: Five Years of darksearch.xyz

There's a whole slice of the internet that's public but almost impossible to search. Content on IPFS is addressed by what it is (a content hash, the CID) rather than where it is, so there's no domain to crawl, no robots.txt, and no single server to point a search engine at. If you don't already have...