On 'Click' Event Works in IOS but not Android


#1

I have a PhoneGap hybrid app developed with Framework7. I have a click event that’s working in IOS, but not Android. Is there an event handler method that works for both?

map.on('click', function(evt){
code here
}

#2

it should work, try

map.on('click tap', function(evt){
  ...
})

Or even better, can you debug the app in android device? if you can, dose the console show some error?


#3

Thanks, I’ll try this. I don’t have an Android device, but I tested it online at Appetize.io and didn’t see any errors in the console.


#4

Ok, i use ADV to test apk’s and Simulator on ipa’s.
Can you share de .apk? (build in debug mode)


#6

Can you build de apk on debug, not release?


#7

Not sure how to do that.


#8

change key to no selected


#9

Thanks.

https://build.phonegap.com/apps/3040375/download/android


#10

I don’t see an error in debug mode either.


#11

Ok, you bind the evt click to an object map

            map = new Map("map", {
            basemap: "hybrid",
               center: [-97, 40],
			  zoom: 3,
			   slider: false
		  
          });

i dont know the map api that you are using, but if you could share the doc it will be helpful. or maybe the map api dosnt support on click event. and you need to listen to the div containing that map.

<div id='map'>
...code...
</div>
$('#map').on('click; mapHandler)

#12

Right. It’s the ArcGIS JS API. Right now I’m binding the click event to the variable map in the JS. I’ll try binding it to the div ID.


#13

A quick read to the API doc, shows that map api donst have event ‘click’

https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html


#14

Yet it works in iOS and in the web versions of this app.


#15

Someone on the ArcGIS JS forum suggested:

map.on('click, touchend', function(evt){
    code here...
});

But this still only works in iOS


#16

A JS programmer at ESRI (ArcGIS) just told me that the map.on(‘click’) method works in Cordova 8 on Android 8, so he believes that it’s an issue with Framework7.


#17

can you try with this apk. Tested on AVD and it works fine.


#19

OK. $$(document).on(“click”) works on both iOS and Android, but sometimes I have to tap a few times to get the popup to come up. Also, sometimes the maps don’t load when I click choose location. I have to go back to the index and try again.


#20

Yes, i notice, your code its a little messy, mutiple times bind same element etc. My suggestion, refactor the code. or re-do the app with what you learn maiking the app the first time. And try to use es-lint. it will help you with bugs you app/code has, like this one.

on(link, "click", function () {
  window
    .navigator
    .notification
    .prompt("Enter Location Name: ", // message
            handleLocationPrompt, // callback
            "", //title
            ["Ok", "Exit"] // button titles);
    // handle user's dialog action
    function handleLocationPrompt(results) {
        if (results.buttonIndex === 1) {
            // Ok
            locationStr = results.input1;
            var lat,
                lon = "";
            lat = x.toString();
            lon = y.toString();
            var taskParams = {
                "Latitude": lat,
                "Longitude": lon,
                "Location": locationStr
            };
            domAttr.set(dom.byId("chartLink_B"), "innerHTML", "Generating Chart...");
            window
                .gp_chart
                .execute(taskParams, gpChartResultAvailable);
        }
  }
});

you dont close
.promt(…)

But it just a suggestion, hope i didnt onfend you in any way.


#21

No offense, I appreciate the help. I’m a GIS (Geographic Information Systems) guy, and I’ve only been coding in Python and JS for a few years. I’m basically teaching myself as I go.

My boss is bugging me to get v1 this app into distribution, so I definitely can’t start over. I’m planning to add features and improve it in v2, but I need to get this working this week. Which elements are being bound multiple times? What do you mean by re-factor?


#22

So I have it working and generating charts on the Android emulator. My coworker is able to get the popup on his Android phone, but it won’t generate charts. I’m watching our server and the charts are being generated from my iPhone and the Android emulator. Nothing happens when he runs the app.