Skip to content

Commit

Permalink
Use GPS provider for Android versions lower than 12
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasMizera committed Aug 30, 2023
1 parent 3f60f03 commit c0ec881
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 19 additions & 2 deletions app/android/src/uk/co/lutraconsulting/PositionTrackingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,24 @@ public int onStartCommand( Intent intent, int flags, int startId ) {

locationManager = ( LocationManager ) getApplication().getSystemService( LOCATION_SERVICE );

boolean isGPSAvailable = locationManager.isProviderEnabled( LocationManager.FUSED_PROVIDER );
if ( Build.VERSION.SDK_INT < Build.VERSION_CODES.O ) {
sendStatusUpdateMessage( "ERROR #UNSUPPORTED: tracking is not supported on your Android version ( Android O (8.0) required )" );
stopSelf();

return START_NOT_STICKY; // do not bother recreating it
}

String positionProvider;

// FUSED_PROVIDER is available since API 31 (Android 12)
if ( Build.VERSION.SDK_INT < Build.VERSION_CODES.S ) {
positionProvider = LocationManager.GPS_PROVIDER;
}
else {
positionProvider = LocationManager.FUSED_PROVIDER;
}

boolean isGPSAvailable = locationManager.isProviderEnabled( positionProvider );
if ( !isGPSAvailable ) {
sendStatusUpdateMessage( "ERROR #GPS_UNAVAILABLE: GPS is not available!" );
stopSelf();
Expand Down Expand Up @@ -192,7 +209,7 @@ public int onStartCommand( Intent intent, int flags, int startId ) {
}

locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
positionProvider,
timeInterval,
distanceInterval,
this
Expand Down
4 changes: 3 additions & 1 deletion app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ ApplicationWindow {
formsStackManager.reopenAll()
}

onNotify: showMessage( message )
onNotify: function ( message ) {
showMessage( message )
}
onAccuracyButtonClicked: {
gpsDataPageLoader.active = true
gpsDataPageLoader.focus = true
Expand Down

1 comment on commit c0ec881

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 23.08.453111 just submitted!

Please sign in to comment.