geolocation - Appcelerator Could not find method android.app.Activity.checkSelfPermission -


i cant seem geo location work on android seem following bug.

[info] :   dalvikvm: not find method android.app.activity.checkselfpermission, referenced method ti.modules.titanium.geolocation.geolocationmodule.haslocationpermissions [warn] :   dalvikvm: vfy: unable resolve virtual method 32: landroid/app/activity;.checkselfpermission (ljava/lang/string;)i [info] :   dalvikvm: not find method android.app.activity.requestpermissions, referenced method ti.modules.titanium.geolocation.geolocationmodule.requestlocationpermissions [warn] :   dalvikvm: vfy: unable resolve virtual method 82: landroid/app/activity;.requestpermissions ([ljava/lang/string;i)v 

my code follows.

ti.geolocation.purpose = "please allow find you."; //ti.geolocation.showcalibration = false; if (os_android) {     titanium.geolocation.android.locationprovider = ti.geolocation.provider_gps; } ti.geolocation.accuracy = ti.geolocation.accuracy_best; ti.geolocation.distancefilter = 10;  ti.geolocation.requestlocationpermissions(ti.geolocation.authorization_always, function(e) {     console.log(e);      if (!e.success || e.error) {          var dialog = ti.ui.createalertdialog({             message : 'you not have location permissions enabled.',             ok : 'got it',             title : 'important'         });          dialog.addeventlistener('click', function(e) {              if (os_ios) {                 ti.platform.openurl('app-settings:');             }              if (os_android) {                 var intent = ti.android.createintent({                     action : 'android.settings.application_settings',                 });                 intent.addflags(ti.android.flag_activity_new_task);                 ti.android.currentactivity.startactivity(intent);             }          });          dialog.show();          return;      }      titanium.geolocation.getcurrentposition(getgeoposition);  }); 

when run stales been @ hours trying debug close giving tried can think of.

appcelerator 5.1.2.ga

full code test

function getgeoposition(_event) {     console.log(_event);     alert(json.stringify(_event)); }  ti.geolocation.purpose = "please allow find you."; ti.geolocation.accuracy = ti.geolocation.accuracy_best; ti.geolocation.distancefilter = 10;  /**  * event listener added in view.  * fired when user taps on ti.geolocation button.  */ function geolocation() {      // new cross-platform way check permissions     // first argument required on ios , ignored on other platforms     var haslocationpermissions = ti.geolocation.haslocationpermissions(ti.geolocation.authorization_always);      if (haslocationpermissions) {         alert('you have permission.');         titanium.geolocation.getcurrentposition(getgeoposition);     }      // on ios can information on reason why might not have permission     if (os_ios) {          // map constants names         var map = {};         map[ti.geolocation.authorization_always] = 'authorization_always';         map[ti.geolocation.authorization_authorized] = 'authorization_authorized';         map[ti.geolocation.authorization_denied] = 'authorization_denied';         map[ti.geolocation.authorization_restricted] = 'authorization_restricted';         map[ti.geolocation.authorization_unknown] = 'authorization_unknown';         map[ti.geolocation.authorization_when_in_use] = 'authorization_when_in_use';          // available since ti 0.8 ios , ti 4.1 windows         // returns authorization_unknown on ios<4.2         var locationservicesauthorization = ti.geolocation.locationservicesauthorization;          if (locationservicesauthorization === ti.geolocation.authorization_restricted) {             alert('because permission restricted policy user cannot change, don\'t request might cause issues.');          } else if (locationservicesauthorization === ti.calendar.authorization_denied) {              alert('you denied permission before');         }     }      // new cross-platform way request permissions     // first argument required on ios , ignored on other platforms     ti.geolocation.requestlocationpermissions(ti.geolocation.authorization_always, function(e) {          if (e.success) {              // instead, call same method call if haslocationpermissions() true             alert('you granted permission.');          } else if (os_android) {             alert('you denied permission now, forever or dialog did not show @ because denied forever before.');          } else {              // check authorization_denied earlier can sure denied , not before             ti.ui.createalertdialog({                 title : 'you denied permission.',                  // end here if nslocationalwaysusagedescription missing tiapp.xml in case e.error                 message : e.error             }).show();         }     }); }  geolocation();  // handle url in case resumed app ti.app.addeventlistener("resume", function() {     geolocation(); }); 

finding latest version ...5.1.0 ✓ version 5.1.0 installed. ? plan on developing titanium apps? yes

checking environment...  have latest titanium sdk release 5.1.2.ga congrats! no issues detected developing cross-platform mobile apps!  appc setup complete! 

update manage working why!!!!

ok managed working going locations setting , turing them off , on again , click agree???? weird cant right? enter image description here

this soooo annoying have everytime locations services work?

update think 1 of main reasons have been getting issue because requesting permissions on every load on post layout event listener seems fix issue.

 var haslocationpermissions = ti.geolocation.haslocationpermissions(ti.geolocation.authorization_always);   if (haslocationpermissions) {      alert('you have permission.');      titanium.geolocation.getcurrentposition(getgeoposition);  } else {      ti.geolocation.requestlocationpermissions(ti.geolocation.authorization_always, function(e) {           if (e.success) {               titanium.geolocation.getcurrentposition(getgeoposition);           } else if (os_android) {              alert('you denied permission now, forever or dialog did not show @ because denied forever before.');           } else {               // check authorization_denied earlier can sure denied , not before              ti.ui.createalertdialog({                  title: 'you denied permission.',                   // end here if nslocationalwaysusagedescription missing tiapp.xml in case e.error                  message: e.error              }).show();          }      });   } 

still seem getting sorts of other issues gps isnt activate each time ill keep @ , report updates.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -