I have made another script listening directly to Location API.

I have made another script listening directly to Location API.

I use it in my car’s head unit for GPS speedometer.

Although GPS speed can be obtained with my other script that takes data from Torque, this one makes it unnecessary to use Torque, and may get data updates just a little bit sooner.

The variables set by script are:

gps_live – boolean – indicates that location API is ready (i.e. enabled and ready)

gps_speed – float – the speed in m/s (must be multiplied by 3.6 to get km/h)

To use, make text with binding like follows:

($gps_speed * 3.6).toFixed(0)

Also, text display can be bound to $gps_live

The script requires a permission which is missing in LLX:

android.permission.ACCESS_FINE_LOCATION

To make it work, either wait for developers to add a permission APK for that, or use this xposed module by Lukas Morawietz (if you are using xposed framework): https://play.google.com/store/apps/details?id=com.faendir.lightning_launcher.permission_manager

— cut —

LL.bindClass(“android.location.LocationManager”);

LL.bindClass(“android.location.LocationProvider”);

LL.bindClass(“android.location.LocationListener”);

LL.getVariables()

.edit()

.setBoolean(“gps_live”, true)

.setFloat(“gps_speed”, 0)

.commit();

var locationManager = LL.getContext().getSystemService(Context.LOCATION_SERVICE);

var locationListener = new LocationListener({

onLocationChanged: function(location) {

if(!location.hasSpeed()) return;

var speed = location.getSpeed();

LL.getVariables()

.edit()

.setFloat(“gps_speed”, speed)

.commit();

},

onProviderDisabled: function(provider) {

LL.getVariables()

.edit()

.setBoolean(“gps_live”, false)

.commit();

},

onProviderEnabled: function(provider) {

LL.getVariables()

.edit()

.setBoolean(“gps_live”, true)

.commit();

},

onStatusChanged: function(provider, status, extras) {

LL.getVariables()

.edit()

.setBoolean(“gps_live”, status == LocationProvider.AVAILABLE)

.commit();

}

});

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

— cut

]]>

4 Commentsto I have made another script listening directly to Location API.

  1. Anonymous says:

    < ![CDATA[

    Nice 👍 and im all for adding more permission apks.FYI the app only has 1 dev.

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Jay M you mean that Pierre Hébert does it alone? Cool and respect!

    ]]>

  3. Anonymous says:

    < ![CDATA[

    aye he does and hes very active here but yano hes french so different time zones and all that good stuff.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    I wish there would be more people to build the project, but that’s not an option at the moment…

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *