How to embed an activity in android which gets activated every time user long presses on any text or url in specific applications , like facebook or whatsapp, on the phone.

1

There are 1 answers

1
CommonsWare On

This is not possible.

The closest thing that fits your requirement is in the upcoming Android M release, where your app can publish an ACTION_PROCESS_TEXT activity. Your activity will then be an option in the floating action mode in an EditText (and perhaps elsewhere with selectable text). If the user chooses your activity's entry in that action mode, your activity will be started and can get at what the user selected.

However:

  • This is not "every time user long presses on any text or url", in that the user still has to choose your activity from the action mode,

  • This is not for "specific applications", but all applications, and

  • Since we are seeing this in a developer preview, it is possible that by the time Android M ships as a production OS, that this feature is dropped or altered