0
我想通過使用intent將「message」字符串傳遞給MainActivity,我嘗試了一切,但仍然沒有運氣。你能幫我解決這個問題嗎?構造函數的意圖是undefined
public class MoveMouse {
public boolean onTouchEvent(MotionEvent event) {
int eventaction = event.getAction();
switch(eventaction) {
case MotionEvent.ACTION_MOVE: {
// new position
final float x = event.getX();
final float y = event.getY();
// get delta
final float deltax = x - this.lastX;
final float deltay = y - this.lastY;
// set last position
this.lastX = x;
this.lastY = y;
String message = (deltax + "," + deltay);
//intent
Intent ins = new Intent(this,MainActivity.class);
ins.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ins.putExtra("mv", message);
this.startActivity(ins);
我不明白,我怎麼定義'Context'? –
如何傳遞參數? –
確實取決於MouseMove類的位置以及如何實例化它。 – laalto