问题
I developed an app that is fun to play with but there are some naughty people who are vandalizing fun of other people by using different type of screen casters and then playing with automated scripts and cheating users.
here is a link to a very famous screen caster. but is there any way to detect it? I think I have read somewhere that I can get tap pressure on accelerometer in android.
please help
回答1:
Sample Application
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);
}
}
来源:https://stackoverflow.com/questions/6293294/how-to-detect-screen-casters-android-detect-tap-pressure