Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 62db354

Browse files
Target API 31 with necessary changes
1 parent 1fae09b commit 62db354

File tree

5 files changed

+32
-27
lines changed

5 files changed

+32
-27
lines changed

LocationUpdatesBackgroundKotlin/app/build.gradle

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@ apply plugin: 'com.android.application'
1717

1818
apply plugin: 'kotlin-android'
1919

20-
apply plugin: 'kotlin-android-extensions'
21-
2220
apply plugin: 'kotlin-kapt'
2321

2422
android {
25-
compileSdkVersion 29
26-
buildToolsVersion "29.0.2"
23+
compileSdkVersion 31
24+
buildToolsVersion "31.0.0"
2725

2826
defaultConfig {
2927
applicationId "com.google.android.gms.location.sample.locationupdatesbackgroundkotlin"
3028
minSdkVersion 15
31-
targetSdkVersion 29
29+
targetSdkVersion 31
3230
versionCode 1
3331
versionName "1.0"
3432
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -44,28 +42,32 @@ android {
4442
dataBinding {
4543
enabled true
4644
}
45+
46+
buildFeatures {
47+
viewBinding true
48+
}
4749
}
4850

4951
dependencies {
5052
implementation fileTree(dir: 'libs', include: ['*.jar'])
5153
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
52-
implementation 'androidx.appcompat:appcompat:1.1.0'
53-
implementation 'androidx.core:core-ktx:1.2.0'
54-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
54+
implementation 'androidx.appcompat:appcompat:1.3.1'
55+
implementation 'androidx.core:core-ktx:1.6.0'
56+
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
5557
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
56-
implementation 'androidx.preference:preference:1.1.0'
58+
implementation 'androidx.preference:preference:1.1.1'
5759

58-
implementation 'androidx.room:room-runtime:2.2.4'
59-
kapt 'androidx.room:room-compiler:2.2.4'
60+
implementation 'androidx.room:room-runtime:2.3.0'
61+
kapt 'androidx.room:room-compiler:2.3.0'
6062

6163
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
62-
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
64+
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
6365
kapt 'com.android.databinding:compiler:3.1.4'
6466

65-
implementation 'com.google.android.gms:play-services-location:17.0.0'
67+
implementation 'com.google.android.gms:play-services-location:18.0.0'
6668

67-
testImplementation 'junit:junit:4.12'
68-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
69-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
70-
implementation 'com.google.android.material:material:1.1.0'
69+
testImplementation 'junit:junit:4.13.2'
70+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
71+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
72+
implementation 'com.google.android.material:material:1.4.0'
7173
}

LocationUpdatesBackgroundKotlin/app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package="com.google.android.gms.location.sample.locationupdatesbackgroundkotlin">
2020

2121
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
22+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
2223
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
2324

2425
<application
@@ -30,7 +31,8 @@
3031
android:theme="@style/AppTheme"
3132
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
3233

33-
<activity android:name=".ui.MainActivity">
34+
<activity android:name=".ui.MainActivity"
35+
android:exported="true">
3436
<intent-filter>
3537
<action android:name="android.intent.action.MAIN" />
3638

@@ -40,11 +42,7 @@
4042

4143
<receiver
4244
android:name=".LocationUpdatesBroadcastReceiver"
43-
android:exported="true">
44-
<intent-filter>
45-
<action android:name="com.google.android.gms.location.sample.locationupdatesbackgroundkotlin.LocationUpdatesBroadcastReceiver.ACTION_PROCESS_UPDATES" />
46-
</intent-filter>
47-
</receiver>
45+
android:exported="false" />
4846
</application>
4947

5048
</manifest>

LocationUpdatesBackgroundKotlin/app/src/main/java/com/google/android/gms/location/sample/locationupdatesbackgroundkotlin/data/MyLocationManager.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import android.Manifest
1919
import android.app.PendingIntent
2020
import android.content.Context
2121
import android.content.Intent
22+
import android.os.Build
2223
import android.util.Log
2324
import androidx.annotation.MainThread
2425
import androidx.lifecycle.LiveData
@@ -81,7 +82,11 @@ class MyLocationManager private constructor(private val context: Context) {
8182
private val locationUpdatePendingIntent: PendingIntent by lazy {
8283
val intent = Intent(context, LocationUpdatesBroadcastReceiver::class.java)
8384
intent.action = LocationUpdatesBroadcastReceiver.ACTION_PROCESS_UPDATES
84-
PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
85+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
86+
PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
87+
} else {
88+
PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
89+
}
8590
}
8691

8792
/**

LocationUpdatesBackgroundKotlin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1818

1919
buildscript {
20-
ext.kotlin_version = '1.3.61'
20+
ext.kotlin_version = '1.5.31'
2121
repositories {
2222
google()
2323
jcenter()
2424

2525
}
2626
dependencies {
27-
classpath 'com.android.tools.build:gradle:3.6.1'
27+
classpath 'com.android.tools.build:gradle:7.0.3'
2828
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2929
// NOTE: Do not place your application dependencies here; they belong
3030
// in the individual module build.gradle files

LocationUpdatesBackgroundKotlin/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

0 commit comments

Comments
 (0)