Andrea
Andrea

Reputation: 449

Two action at the same time, android

I have a doubt, is it possible to have two independent actions at same time in a single thread?

For example, when you build a custom view you have to override onTouchEvent() function that is called every time you touch the screen and also while you are touching it; but what happens when you run a function that loops infinitely in MotionEvent.ACTION_DOWN and the system call MotionEvent.ACTION_UP? Will the infinite loop function stop or will they work together?

Thanks for any help.

Upvotes: 0

Views: 177

Answers (1)

Clapa Lucian
Clapa Lucian

Reputation: 600

well, if you run an infinite loop there you will block the ui thread so you will block your app. If you are trying to stop action_up or action_down even you can't, at least not this way.

onTouchEvent it's just a callback function that you receive after the touch has been done. You are just receiving the result so you can't block the input from the callback.

Upvotes: 1

Related Questions