I have implemented ontouchlistener in my service class and trying to get the touch event which is working well with gingerbread but it is not working with higher than icreamsandwich. I am trying a lot to solve this but I am not getting any solution even after reading a lot of documents in stackoverflow,

Here is the code ..please help me solve this problem. In onCreate method I have defined ImageButton

3 Answers
3

why you are returning false ? you should return true on touch listener !!
sorry but can you tell me what you want to do with the touch listener ? as i can see on your code you only showing Toast. if you want to perform on click . just use OnClickListener instead of touch listener !

response to your Comment. well you can use OnClickListener instead for double clicks or more!

here is an example : first you create a Boolean variable and assign it to true

boolean lightit = true;

second create the method for the button clicks. in my example here when first time i click the button image will change to another one. and when the button clicked again it change it back to the old image. follow my example here and hope it helps you in anyway.

and then on your button Click Listener add this showHide();
this is how i handle clicks on a button or imageview. for multiple clicks you just need to add if else . Please see i'm using the same method to show and hid the statusBar in fullScreen but i'm using Gesture instead of OnTouchListener . tell me if you like to know how i use the Gesture is easier to use.