Skip to content

Commit

Permalink
fix location quest
Browse files Browse the repository at this point in the history
  • Loading branch information
nethical6 committed Jul 14, 2024
1 parent b74e687 commit 8c5d0de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/src/full/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_TYPE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

<application>
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,13 @@ public void onLocationChanged(Location location) {
radarLocation.getLongitude());
serviceIntent.putExtra("radius",travelRadius);
serviceIntent.setAction("START");
requireContext().startForegroundService(serviceIntent);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ContextCompat.startForegroundService(requireContext(), serviceIntent);
} else {
requireContext().startService(serviceIntent);
}


} else {
startQuest.setText(R.string.start);
Expand Down Expand Up @@ -316,7 +322,7 @@ private void checkNotificationPermision() {
}

private void checkLocationPermission() {
if (ContextCompat.checkSelfPermission(
if (ContextCompat.checkSelfPermissions(
requireContext(), Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
loadingDialog.dismiss();
Expand Down Expand Up @@ -350,7 +356,7 @@ private MaterialAlertDialogBuilder makeLocationPermissionDialog() {
"Provide",
(dialog, which) -> {
requestPermissions(
new String[] {Manifest.permission.ACCESS_FINE_LOCATION},
new String[] {Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.FOREGROUND_SERVICE_LOCATION},
REQUEST_FINE_LOCATION_PERMISSION);
});
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ServiceInfo;
import android.location.Location;
import android.os.CountDownTimer;
import androidx.core.app.NotificationCompat;
Expand Down Expand Up @@ -76,7 +77,7 @@ private void showNotification() {
.setOnlyAlertOnce(true)
.setPriority(NotificationCompat.PRIORITY_HIGH);

startForeground(70, builder.build());
startForeground(70, builder.build(),ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION);
}

private void updateNofification(String title,String content,int priority) {
Expand Down

0 comments on commit 8c5d0de

Please sign in to comment.