I want to send a system multi-touch event to Android. I found someone asking online, but no one has the answer ~ No one answered after I posted the post ~ It took a long time to figure it out ~ Google's real TMD doesn't have a document. Let's look at an example ~
Paste the code ~ The following are suitable for 2.2 ~
Public Boolean sendmovedouble ()
{
// Point 1 release first
Log. I ("key", "199199 send sendmovedoubl ...... e ");
Instrumentation inst = new instrumentation ();
Motionevent E;
// Nano
E = motionevent. obtainnano (systemclock. uptimemillis (),
Systemclock. uptimemillis (), system. nanotime (),
0, 1, new int [] {0 },
New float [] {bx1, by1, 1, 1}, 0,
0, 0, 0, 0 );
Log. I ("key", "199199 send sendmovedoubl... 1 ");
Inst. sendpointersync (E );
Systemclock. Sleep (200); // MS
E = motionevent. obtainnano (systemclock. uptimemillis (),
Systemclock. uptimemillis (), system. nanotime (),
261, 2, new int [] {0, 1 },
New float [] {bx1, by1, 1, 1, ex1, ey1, 1, 1}, 0,
0, 0, 0, 0 );
Log. I ("key", "199199 send sendmovedoubl... 2 ");
Inst. sendpointersync (E );
Systemclock. Sleep (200); // MS
E = motionevent. obtainnano (systemclock. uptimemillis (),
Systemclock. uptimemillis (), system. nanotime (),
2, 2, new int [] {0, 1 },
New float [] {bx2, by2, 1, 1, ex2, EY2, 1, 1}, 0,
0, 0, 0, 0 );
Log. I ("key", "199199 send sendmovedoubl ...... 3 ");
Inst. sendpointersync (E );
Systemclock. Sleep (200); // MS
E = motionevent. obtainnano (systemclock. uptimemillis (),
Systemclock. uptimemillis (), system. nanotime (),
6, 2, new int [] {0, 1 },
New float [] {bx2, by2, 1, 1, ex2, EY2, 1, 1}, 0,
0, 0, 0, 0 );
Inst. sendpointersync (E );
Systemclock. Sleep (200); // MS
Log. I ("key", "199199 send sendmovedoubl ...... 4 ");
E = motionevent. obtainnano (systemclock. uptimemillis (),
Systemclock. uptimemillis (), system. nanotime (),
1, 1, new int [] {1 },
New float [] {bx2, by2, 1, 1}, 0,
0, 0, 0, 0 );
Log. I ("key", "199199 send sendmovedoubl ...... 5 ");
Inst. sendpointersync (E );
Return true;
}
Motionevent. obtainnano: this function is 2.2. It is not in the SDK. You must have the android source code and compile it in the source code to link to it! This function is not displayed in the SDK.
Using this code, I successfully zoomed in and out in 2.2.