获取坐标触摸屏的后台服务触摸屏、坐标、后台

2023-09-05 05:18:28 作者:半城繁华半城殇

我只是想知道知道,如果有一个后台服务一个可以负责协调所有活动触摸屏事件。 这样那样的

 
*最后的TextView TextView的=(的TextView)findViewById(R.id.textView);
最后查看的TouchView = findViewById(R.id.touchView);
touchView.setOnTouchListener(新View.OnTouchListener(){
    @覆盖
    公共布尔onTouch(视图V,MotionEvent事件){
              textView.setText(触摸坐标:+将String.valueOf(event.getX())+×+将String.valueOf(event.getY()));
     返回true;} 

但没有任何默认视图。 谢谢

解决方案   

我只是想知道知道是否能   与后台服务有   坐标触摸屏事件   在所有的活动。

没有,对不起。你的活动,可以通过有关触摸事件的服务的信息,而是一种服务不能直接接收触摸事件。

怎么获取屏幕中心点的坐标

I'm just wondering to know if a can with a background service have co-ordinates of a touch screen event in all activities. Such like that


*final TextView textView = (TextView)findViewById(R.id.textView);
final View touchView = findViewById(R.id.touchView);
touchView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
              textView.setText("Touch coordinates : " +String.valueOf(event.getX()) + "x" + String.valueOf(event.getY()));
     return true;}

but without any view by default. Thanks

解决方案

I'm just wondering to know if a can with a background service have co-ordinates of a touch screen event in all activities.

No, sorry. Your activities can pass information about touch events to a service, but a service cannot directly receive touch events.