2

I've only recently started using BroadcastReceivers, and I wanted to create a service that would be triggered when someone long pressed on an editText. I think on one of my older phones (Original EVO 4G), there was a listener to change the input method if you long pressed on the editText. Now (if there is text in the field) and you long press it, then the options to cut copy and paste come up.

I was wondering what intent-filters I should use for my broadcast receiver (if possible) to listen for long press events on editTexts (outside of my application i.e. like in a web browser), so that I could trigger my application?

Kara
  • 6,115
  • 16
  • 50
  • 57
Khang Le
  • 23
  • 2

1 Answers1

1

I was wondering what intent-filters I should use for my broadcast receiver (if possible) to listen for long press events on editTexts

BroadcastReceiver don't listen for long click events, but OnLongClickListeners do.

editText.setOnLongClickListener(new OnLongClickListener() {
    @Override
    public boolean onLongClick(View v) {
        // Do something
        return false;
    }
})

(outside of my application i.e. like in a web browser), so that I could trigger my application?

I don't believe this is possible.

Sam
  • 86,580
  • 20
  • 181
  • 179
  • Yeah. I had already looked at the possibility of using an onLongClickListener, but it can't really be used outside of your own interface. Are you sure there is no possibility? What does the cut, copy, paste box sense to pop up when you long click on a textview/editText in a browser? – Khang Le Nov 30 '12 at 20:51
  • I haven't tried to do it myself, but it appears you cannot do this: [Android Long Press on Edit Text behavior](http://stackoverflow.com/q/4181309/1267661) – Sam Nov 30 '12 at 20:57