How do Android applications receive input from touch screen? -
i want know how applications handle input touch screen. example, if user touch coordinates x,y, how opened (active in foreground) application know gadget (button example) @ coordinates x,y must clicked now?
also, can control way apps handle touch input using app? mean, want build app uses services
control how other apps handle inputs, of course needs app have permission
access other apps settings, question is, possible?
i have searched how apps handle touch input, found these results, useful, not relevant case,
http://developer.android.com/training/gestures/index.html
how android device handle touch screen input?
also, know input hardware controlled hal (hardware abstraction layer)
in android, every input device has own driver. how apps handles inputs coming these devices?
thank you.
there several ways handle touches in android.
first buttons can set onclick()
method automatically triggered when touch screen.
another option attach ontouchlistener
activity.
in example custom view class called "example" id "exampleid" getting attached "ontouchlistener
public class example extends view implements view.ontouchlistener { public example(context context) { example exampleview = (example) findviewbyid(r.id.exampleid); //this how set ontouch listener. gameview.setontouchlistener(this); } @override public boolean ontouch(view v, motionevent event) { //do when touched. } }
Comments
Post a Comment