Think of a scenario any application is running, and the user selected some text on that application’s activity screen. I want to grab that selected text through a service running in the background and process that text in the service. Text can be selected from any application like SMS, browser, or contacts from anywhere.
Can anyone show me the way to grab the text?
You can’t grab the selected text, but i think it’s possible for the text which is copied in the clipboard.
See http://developer.android.com/reference/android/content/ClipboardManager.html and getPrimaryClip ()