Added permission request

This commit is contained in:
wiecktobi 2020-05-18 21:52:52 +02:00
parent 10a1d3a3fa
commit 65fc373f97
2 changed files with 18 additions and 1 deletions

View File

@ -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())

View File

@ -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()
}