如何检测屏幕脚轮android,检测敲击压力
问题描述:
我开发了一个有趣的应用程序,但有一些淘气的人是通过使用不同类型的屏幕脚轮肆意破坏其他人的乐趣,然后自动播放脚本和欺骗用户。如何检测屏幕脚轮android,检测敲击压力
here is a link到一个非常有名的屏幕施法者。但有什么方法可以检测到它?我想我已经读过一些地方,我可以在Android中获取加速度计的敲击压力。
请帮助
答
示例应用程序
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);
}
}
http://developer.android.com/reference/android/view/MotionEvent.html#getPressure(int) – 2011-06-09 13:20:07
你可以去联系,有是MotionEvent检测压力的方法,但没有尝试过。 – 2011-06-09 13:20:36
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/TouchPaint.html一个关于但不完全是我想要的例子 – 2011-06-09 13:30:37