HTML loading SWF, code emulation click event

Source: Internet
Author: User

I. BACKGROUND

1, recently in doing a Android side play Flash application, Android device does not have a screen, the display needs to be connected via HDMI. The interaction between JavaScript and Java needs to be used, and the Android side receives flash-transmitted Fscommand.

2, want to load HTML through WebView implementation

Second, encounter problems

1, through the HTML after loading the animation, regardless of which button, the SWF file can not receive the key message, it can not implement some of its own operational features

2, sent over the command received (there is time to analyze this, has been resolved)

Iii. Methods of trial

1, found that if directly through the computer side using the browser to open the HTML, directly tapping the keyboard is not effective, mouse click, the button has effect

2, did not receive the command, by adding the Flash security sandbox path can, of course, you have to install Flash Player

3, by guessing that should be webview start time did not get to the focus, so the key event has not been captured

Iv. Successful Solution

1. HTML Loading main.swf

<! DOCTYPE HTML PUBLIC "-//wapforum//dtd XHTML Mobile 1.0//en" "Http://www.wapforum.org/DTD/xhtml-mobile10.dtd" >< HTML xmlns= "http://www.w3.org/1999/xhtml" >
which

Width= "100%" height= "100%"
This is based on the device full screen, for different resolutions of different screen size devices, this property is necessary

2, Analog Click event, you can add the following code after the HTML loaded successfully

Mwebview.dispatchtouchevent (Motionevent.obtain (Systemclock.uptimemillis (), Systemclock.uptimemillis (), Motionevent.action_down, Mwebview.getleft () + 5,mwebview.gettop () + 5, 0); Mwebview.dispatchtouchevent ( Motionevent.obtain (Systemclock.uptimemillis (), Systemclock.uptimemillis (), MOTIONEVENT.ACTION_UP, Mwebview.getleft () + 5,mwebview.gettop () + 5, 0));

3, add a secure path to the Android side, so far to achieve the desired effect




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.