Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to listen for a copy in Android

Tags:

java

android

To get myself a little more familiar with content providers in Android, I'm making a small clipboard manager app. Its core functionality is to simply add whatever you copy to a database to display. I'm somewhat familiar with Android's Clipboard framework, but what I'm not sure how to do is to listen for copy "events" to know that a new item needs to be added to the clipboard.

To clarify, I need to be able to add a record to the database whenever the user copies something. How do I do this?

like image 248
Tyler Treat Avatar asked Aug 03 '11 18:08

Tyler Treat


1 Answers

If you are using API level 11 (3.0) or above, then you can use addPrimaryClipChangedListener which is documented here and there is some example usage here.

like image 189
Eugene S Avatar answered Sep 21 '22 02:09

Eugene S