problem with ketai gps

edited April 2018 in Android Mode

Hi everyone, i have an app that uses ketai gps, and it was working all fine and now it doesn't, the coordinates that throws are 0, 0, 0, it's like i have no signal, but when i switch to google maps i have the location, no changes where made to the code, could this be because an android update? if this is the case, what should i do?

Tagged:

Answers

  • There are few things that could have been updated.

    Processing

    Android Mode in Processing

    Ketai also was updated to reflect the latest Android mode version. I am not sure if the updated Ketai is compatible with an older Android Mode version. To Clarify, there is a core difference in the Android mode and you need to be aware if you are working with AM version 3.xxx or 4.xxx

    To capture this problem properly, could you tell what changed in your setup? Did you updated your Android mode? Your ketai? Or are you using a different mode?

    I don't have much experience but maybe you need to manage your permissions. If you google "Android developers manage permissions" you should get some instructions of how permissions should be managed. You can add that code in Processing.

    There will be some troubleshooting you need to do on your side as your problem won't be easy to reproduce. If you document changes in your systems (version changes) would be a good start. If you load your code in a repo in github, I could trying running it this weekend.

    Kf

  • my settings are:

    AM is 4.0.1 ketay is v14 android version is 7.0

    the only change that i can remember is updating the andorid from my phone, the permissions remain the same (since i didn't change the app), trying out the ketay examples, the same happens (latitude and longitude remains on 0), i could try to verify if the program works on the same phone but with the original android version.

    thanks.

  • edited April 2018 Answer ✓

    @erwrow===

    i dont know what is happening for your app; what i know is that there are a lot of cases in which for various reasons ketai does not work. So, as ketai is only a wrapper for android, i think that it is more sure to use android API.

    As for location there are many ways to do that; you can use googlePlayservice or code yourself : firstly you create an instance of LocationManager which is a system service; after that you create a Location object with your LocationManager and now you can get your location (double latitude, double longitude): snippet here::

        double latitude, longitude;
    
    
        LocationManager locationMan = (LocationManager)this.getActivity().getSystemService(Context.LOCATION_SERVICE); 
        Location location = locationMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        longitude = location.getLongitude();
        latitude = location.getLatitude();
    

    In order to be more efficient you can add a listener to your locationManager, implementing the required methods and commenting the 2 lines where it is called for latitude && longitude.

            LocationListener locationListener= new LocationListener() {
                public void onLocationChanged(Location location) {
                    longitude = location.getLongitude();
                    latitude = location.getLatitude();
                }
    
                 public void onProviderDisabled(String provider) {
            //alert the user:Called when the provider is disabled by the user: "are you sure?"
                }
    
                //@Override
                public void onProviderEnabled(String provider) {
    

    //Called when the provider is enabled by the user. }

                //@Override
                public void onStatusChanged(String provider, int status, Bundle extras) {
    

    //could be OUT_OF_SERVICE, AVAILABLE, TEMPORARLY_UNAVAILABLE //alert the user } };

    locationMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, locationListener);// the 2 integer values define the time and distance, in this case each 2" and each 10 meters.
    

    i have used this code or rather this kind of code for a lot of times and i am sure that it works; of course you must have the (3) permissions granted (and test that at runtime); of course also before instantiating the LocationManager you have to test the network (is wifi or mobile available...) and choose the provider.

Sign In or Register to comment.