Skip to content

Commit 4795013

Browse files
committed
Foreground service type
1 parent b1085bf commit 4795013

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

AndroidProject/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
66
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
77
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
8+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
89

910
<application android:name=".Bridge">
1011
<service
1112
android:name=".PedometerService"
1213
android:enabled="true"
14+
android:foregroundServiceType="specialUse"
1315
android:exported="true" />
1416
</application>
1517
</manifest>

AndroidProject/app/src/main/java/com/kdg/toast/plugin/PedometerService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class PedometerService : Service(), SensorEventListener {
4545
val notificationIntent = Intent(this, Bridge.myActivity.javaClass)
4646
val pendingIntent = PendingIntent.getActivity(
4747
this,
48-
0, notificationIntent, 0
48+
0, notificationIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
4949
)
5050
val notification = NotificationCompat.Builder(this, "PedometerLib")
5151
.setContentTitle("Background Walking Service")

0 commit comments

Comments
 (0)