如何在安卓设备上检测屏幕录制,检测点击压力。

3
我开发了一个有趣的应用程序,但是有一些不良分子正在使用不同类型的屏幕投影工具,并使用自动脚本来破坏其他用户的乐趣并欺骗用户。 这里是一个链接到一个非常著名的屏幕投影工具。但是有没有办法检测它?我想我在某个地方读到过可以在Android中使用加速度计获取点击压力的方法。
请帮忙。

http://developer.android.com/reference/android/view/MotionEvent.html#getPressure(int) - AZ_
你可以前往链接,那里有一个在MotionEvent上检测压力的方法,但我还没有尝试过。 - AZ_
这是一个与我想要的不完全相关但相关的示例:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html - AZ_
1个回答

1

示例应用程序

package com.pressure.detection;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

public class StartActivity extends Activity implements View.OnTouchListener {
    /** Called when the activity is first created. */

 private TextView tvConsole;

    @Override
    public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 findViewById(R.id.root_layout).setOnTouchListener(this);

 tvConsole = (TextView)findViewById(R.id.txtConsole);
    }

    @Override
    public boolean onTouch(View view, MotionEvent mEvent) {
    tvConsole.setText("Pressure: "+mEvent.getPressure() );


 System.out.println("Hardware X " + mEvent.getXPrecision()
  * mEvent.getX());
 System.out.println("Hardware Y " + mEvent.getYPrecision()
  * mEvent.getY());
 return super.onTouchEvent(mEvent);
    }

}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接