Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

javascript - Phonegap on Galaxy S3 ignores touch events

I am having a really odd issue. I have a Phonegap 2.0 app that is basically completed. It is working on iPhone and iPad and I ported it over to Android in a day, testing it on my Galaxy S. Everything worked perfectly. Then I tried to run it on my brand new S3 and none of the touch events worked. Clicks work, but not touch.

If I run this code:

document.addEventListener('touchstart', function (e) { console.log('touch start')}, false);
document.addEventListener('click', function (e) { console.log('doc click'); }, false);

... only the click events logs. If I comment out the click I get nothing but the system clicks.

10-12 10:08:16.213: V/webview(2805): NO_FAST_DRAW = false
10-12 10:08:16.283: V/webview(2805):  singleCursorHandlerTouchEvent -getEditableSupport  FASLE 

The really weird thing is that the same touchstart works both on the S3 browser AND the PhoneGap ChildBrowser plugin. Just not in the webview portion of the app, and only on the S3.

[UPDATED]

And it gets weirder. If I bind the event in the inline JavaScript code, such as this

// Javascript stuff
document.addEventListener('touchstart', function (e) { alert('touch start')}, false);
// more JavaScript stuff

it actually works. However, if I set it after a timeout it doesn't

setTimeout(function() {
    document.addEventListener('touchstart', function (e) { alert('touch start')}, false);
}, 2000);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm very sad to say, it looks like Ice Cream Sandwich does not support touch events (http://stackoverflow.com/questions/11390902/webview-in-ics-touch-events-not-being-fired-properly). So iOS supports touch* events, Galaxy S supports touch* and mouse* and Ice Cream Sandwich (S3) does not support touch*. Egads. I hope I'm wrong.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...