Create a foreground service.

This commit is contained in:
Onuray Sahin 2022-03-18 15:26:11 +03:00
parent 3547c5acba
commit a1d27940cd
3 changed files with 36 additions and 1 deletions

View file

@ -46,6 +46,7 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- Jitsi SDK is now API23+ -->
<uses-sdk tools:overrideLibrary="org.jitsi.meet.sdk,com.oney.WebRTCModule,com.learnium.RNDeviceInfo,com.reactnativecommunity.asyncstorage,com.ocetnik.timer,com.calendarevents,com.reactnativecommunity.netinfo,com.kevinresol.react_native_default_preference,com.rnimmersive,com.corbt.keepawake,com.BV.LinearGradient,com.horcrux.svg,com.oblador.performance,com.reactnativecommunity.slider,com.brentvatne.react" />
@ -84,8 +85,8 @@
android:resizeableActivity="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Vector.Light"
android:taskAffinity="${applicationId}.${appTaskAffinitySuffix}"
android:theme="@style/Theme.Vector.Light"
tools:replace="android:allowBackup">
<!-- No limit for screen ratio: avoid black strips -->
@ -369,6 +370,11 @@
</intent-filter>
</service>
<service
android:name=".features.location.LocationSharingService"
android:exported="false"
android:foregroundServiceType="location" />
<!-- Receivers -->
<receiver

View file

@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.features.location
import android.app.Service
import android.content.Intent
import android.os.IBinder
class LocationSharingService : Service() {
override fun onBind(intent: Intent?): IBinder? {
return null
}
}

View file

@ -26,7 +26,9 @@ import androidx.core.location.LocationListenerCompat
import im.vector.app.BuildConfig
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class LocationTracker @Inject constructor(
context: Context
) : LocationListenerCompat {