diff --git a/android/app/src/main/java/de/hft/geotracker/activities/Login.kt b/android/app/src/main/java/de/hft/geotracker/activities/Login.kt index 5de4b5b..9857068 100644 --- a/android/app/src/main/java/de/hft/geotracker/activities/Login.kt +++ b/android/app/src/main/java/de/hft/geotracker/activities/Login.kt @@ -1,11 +1,15 @@ package de.hft.geotracker.activities +import android.Manifest import android.content.Intent +import android.content.pm.PackageManager import android.os.Bundle import androidx.fragment.app.Fragment import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat import de.hft.geotracker.* import de.hft.geotracker.data.JWToken import de.hft.geotracker.retrofit.GeofenceService @@ -29,6 +33,19 @@ class Login : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_login) + if (ContextCompat.checkSelfPermission(this, + Manifest.permission.ACCESS_BACKGROUND_LOCATION + ) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions( + this, + arrayOf(Manifest.permission.ACCESS_BACKGROUND_LOCATION), + 1000 + ) + } else { + // Background location runtime permission already granted. + // You can now call geofencingClient.addGeofences(). + } + val retrofit = Retrofit.Builder() .baseUrl("http://plesk.icaotix.de:5000") .addConverterFactory(GsonConverterFactory.create()) diff --git a/android/app/src/main/java/de/hft/geotracker/activities/MainActivity.kt b/android/app/src/main/java/de/hft/geotracker/activities/MainActivity.kt index 902a9b9..2d89506 100644 --- a/android/app/src/main/java/de/hft/geotracker/activities/MainActivity.kt +++ b/android/app/src/main/java/de/hft/geotracker/activities/MainActivity.kt @@ -111,7 +111,7 @@ class MainActivity : AppCompatActivity() { } private fun getGeofencingRequest() : GeofencingRequest { return GeofencingRequest.Builder().apply { - setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_DWELL) + setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER) addGeofence(geofence) }.build() }