I'm making a custom layout for my app notification which has few buttons in the custom layout, now I'm interested in having different functionalities for a single tap and a double tap on those buttons. I'm currently using setOnClickPendingIntent to register any click/tap event on those buttons. By using this I can easily figure out when an user taps on the button and on which button, but unfortunately I'm not able to figure out any way of knowing whether it was a single tap or a double. Can someone please help me out with this? I just want to differntiate between the single tap and double tap on the button that is inside my custom notification layout.
Asked
Active
Viewed 238 times
1 Answers
0
The proper way to detect a double tap interaction is with the GestureDetector
. You can also use this to detect long presses. You'll find sample code here. Look for setOnDoubleTapListener
.

jspcal
- 50,847
- 7
- 72
- 76
-
Yes, true, but I don't think that I can use gestureDetector or even OnClickListener on the buttons inside my custom layout for the notification. I guess the only way to listen to the taps is through using setOnClickPendingIntent (refer [this](https://stackoverflow.com/a/26486425/8314329)). So, I don't think that will work. – Ajay Deshmukh May 21 '18 at 13:40
-
Are you able to insert a custom view class into the layout that does gesture detection? – jspcal May 21 '18 at 18:18
-
Yes, I can insert a custom view class into the layout but the only problem is that we don't have any concept of onClickListener or gestureDetector inside the notification. We are bound to use the setOnClickPendingIntent which takes just two arguments, i.e. viewId and pendingIntent, and launch the pendingIntent when the user taps on the corresponding view on its own. This onClickListener or gestureDetector nowhere comes into the picture and that is where the problem begins. – Ajay Deshmukh May 22 '18 at 06:16