-
-
Save dzwillpower/5410068 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.touch; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.util.Log; | |
import android.view.MotionEvent; | |
import android.view.View; | |
import android.webkit.ConsoleMessage; | |
import android.webkit.WebChromeClient; | |
import android.webkit.WebView; | |
public class MyActivity extends Activity { | |
private Handler handler = new Handler(); | |
/** | |
* Called when the activity is first created. | |
*/ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
final View myView =findViewById(R.id.myView); | |
myView.setOnTouchListener(new View.OnTouchListener() { | |
@Override | |
public boolean onTouch(View view, MotionEvent event) { | |
Log.d("autotouch", "on touch: " + event); | |
return true; | |
} | |
}); | |
handler.postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
MotionEvent event = MotionEvent.obtain(System.currentTimeMillis(), | |
System.currentTimeMillis() + 100, | |
MotionEvent.ACTION_DOWN, 10, 10, 1, 1, 0, 1, 1, 6, 0); | |
myView.dispatchTouchEvent(event); | |
handler.postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
MotionEvent event = MotionEvent.obtain(System.currentTimeMillis(), | |
System.currentTimeMillis() + 100, | |
MotionEvent.ACTION_UP, 10, 10, 1, 1, 0, 1, 1, 6, 0); | |
myView.dispatchTouchEvent(event); | |
} | |
}, 100); | |
} | |
}, 2000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test