Topic
12 replies Latest Post - ‏2013-02-12T05:54:13Z by IdanAdar
pandrbox
pandrbox
22 Posts
ACCEPTED ANSWER

Pinned topic click event doesn't fire on Adndroid 4.1

‏2013-02-10T10:11:28Z |
On following code with Worklight 5.0.5.1 ( Dojo mobile 1.8.1-20121024-IBM )

<div data-dojo-type=
"dojox.mobile.ScrollableView" id=
"view0" data-dojo-props=
"selected:false,scrollDir:'v'"> <div data-dojo-type=
"dojox.mobile.ScrollablePane"> <div id=
"target">Tap here!</div> </div> </div>

onclick event doesn't fire on Android 4.1 ( GALAXY Notes II ). I had tested on some other devices ( iOS 5, Android 2.2, 2.3 etc ) then works fine.
I tested by dojo.connect with following code, but same.

dojo.connect(dojo.byId('target'), "onclick", function(){alert('tapped');});

Do any one has way to solve this ?
  • pandrbox
    pandrbox
    22 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-11T08:00:28Z  in response to pandrbox
    I'm sorry, code was not written correctly.
    
    <div data-dojo-type=
    "dojox.mobile.ScrollableView" id=
    "view0"    data-dojo-props=
    "selected:false,scrollDir:'v'">    <div data-dojo-type=
    "dojox.mobile.ScrollablePane">       <div onclick=
    "alert('tapped.');">Tap here!</div>    </div>
    

    Regards,
    • Eric Durocher
      Eric Durocher
      38 Posts
      ACCEPTED ANSWER

      Re: click event doesn't fire on Adndroid 4.1

      ‏2013-02-11T09:07:28Z  in response to pandrbox
      Hi,

      Just to complement Idan's reply, we fixed a defect around this in Dojo 1.8.1: http://trac.dojotoolkit.org/ticket/15878. The problem was that click events were duplicated on Android 4.1 because of a behavior change wrt previous Android version. What you describe may indicate that the fix should actually not be applied to that particular device (Galaxy Note II). Unfortunately we don't have that particular device, but we tested on several other Android 4.1 devices (including a Galaxy S3) and the behavior was consistent with the fix. I also tested on a remote Galaxy Note II emulator and could not reproduce the problem.

      Note that I tested in pure web applications using the Android browser. Could we ask you to also test this? That is, try to run the minimal sample as a simple web application, without Worklight, on the Galaxy Note browser?

      Thanks,

      Eric
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-11T08:00:45Z  in response to pandrbox
    Hi,
    I am not familiar with Dojo, but let us try to minimize the problem.

    Please create a new application that all it does is utilize the onClick event, and test this application on Android 2.x and 4.x (including a device that is not Galaxy Note 2) and see if the problem persists.
    If it persists, I would say the problem is on the Android support-side, perhaps on Galaxy Note 2 devices.

    In addition, on Mobile I would recommend to use the start-touch and end-touch events.
    See:
    http://www.sitepen.com/blog/2011/12/07/touching-and-gesturing-on-iphone-android-and-more/
    http://jquerymobile.com/

    ===
    Note: IBM forums are in the process of migrating to a new format. During migration the forums will be frozen and in read-only mode. If you wish to continue this thread discussion please post it on stackoverflow, where the Worklight team and others can respond.

    See the Forum Migration announce post for more details. Thank you.
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14937476

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
  • pandrbox
    pandrbox
    22 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-11T09:33:43Z  in response to pandrbox
    Thank you, Eric.
    I'm using Dojo mobile 1.8.1-20121024-IBM and tested also as simple web application. Do you mean the problem has been fixed on the version of Dojo mobile ?
    My problem is not duplicate of click event. The click event doesn't fire.
    • Eric Durocher
      Eric Durocher
      38 Posts
      ACCEPTED ANSWER

      Re: click event doesn't fire on Adndroid 4.1

      ‏2013-02-11T10:30:33Z  in response to pandrbox
      No, what I mean is that the fix could cause the problem, if the Galaxy Note II does not behave like other Android 4.1 devices.

      Could I ask you to test this standalone html?

      <!DOCTYPE HTML>
      <html>
      <head>
      <title>Tap/Click test</title>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="viewport"
      content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
      <meta name="apple-mobile-web-app-capable" content="yes" />
      <script type="text/javascript" charset="utf-8">
      function onLoad(){
      document.getElementById("view").addEventListener("touchstart", function(e) {
      e.preventDefault();
      });
      }
      </script>
      </head>
      <body onload="onLoad()">
      <div id="view">
      <div onclick="alert('Click event received');">Tap here!</div>
      </div>
      </body>
      </html>

      What we observed so far is that the preventDefault() call prevents the click events, on all devices except Android 4.1 (and later). So, in dojox/mobile/ScrollableView (where we must call preventDefault to prevent native page scrolling by the browser), we sent a synthetic "click" event in case someone was listening to it. Since we saw that Android 4.1 did sent the "click" event, even if preventDefault() was called, we did not send the synthetic event on Android 4.1 (otherwise 2 clicks would be sent - that was the defect I sent you).

      Now, what you describe would seem to indicate that the behavior may be different on Galaxy Note II? So the above test would be useful to verify this.

      Thanks,

      Eric
  • pandrbox
    pandrbox
    22 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-11T09:42:40Z  in response to pandrbox
    I've checked my code. 15878.patch had been applied on my environment.
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-11T10:30:26Z  in response to pandrbox
    What about my experiment? Have you tried minimizing the issue as suggested?

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
  • pandrbox
    pandrbox
    22 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-11T11:10:57Z  in response to pandrbox
    I tested with Android emulator 4.1.2 on ARM runtime then it works.
    My colleague said his Android has same problem. Checking his version and device.
  • pandrbox
    pandrbox
    22 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-11T11:36:06Z  in response to pandrbox
    Eric, the code that you posted caused same problem. The click event doesn't fire.
  • pandrbox
    pandrbox
    22 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-12T03:18:55Z  in response to pandrbox
    I tested on following devices with browser as web application.

    iPhone5 : ( iOS6 ) - OK
    iPad : ( iOS5 ) - OK
    GALAXY TAB SC-01C : (Android 2.3.6) - OK
    LYNX 3D SH-03C ( Android 2.3.6 ) - OK
    GALAXY Nexus SC-04D : ( Android 4.1.1) - OK
    Android 4.1.2 emulator : - OK

    GALAXY S SC-02B : (Android 2.3.6) - NG
    GALAXY Note II SC-02E : ( Android 4.1.1) - NG

    It seems SC-02 product line has the problem.
  • pandrbox
    pandrbox
    22 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-12T03:41:22Z  in response to pandrbox
    Eric,

    I have been suggested by our development member in Tokyo inserting following line as test.

    require(, function(has){ has.add('android', 4.0, false, true); });

    Then, click event fired on Galaxy Note II.
    Hopefully it must be help you understand the problem.
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: click event doesn't fire on Adndroid 4.1

    ‏2013-02-12T05:54:13Z  in response to pandrbox
    Important Note: IBM forums are in the process of migrating to a new format. During migration the forums will be frozen and in read-only mode. If you wish to continue this thread discussion please post it on stackoverflow, where the Worklight team and others can respond.

    See the Forum Migration announce post for more details. Thank you.
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14937476

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform