@@ -145,23 +145,33 @@ class GPSUpdatesForegroundService : LifecycleService() {
145
145
private fun defaultNotificationBuilder (builder : NotificationCompat .Builder ): NotificationCompat .Builder {
146
146
val pendingIntent =
147
147
packageManager.getLaunchIntentForPackage(this .packageName)?.let { intent ->
148
- intent.putExtra(GPS_SERVICE_NOTIFICATION , ACTION_STOP_TRACKING )
149
148
PendingIntent .getActivity(
150
149
this ,
151
150
0 ,
152
151
intent,
153
152
PendingIntent .FLAG_UPDATE_CURRENT or PendingIntent .FLAG_IMMUTABLE
154
153
)
155
- } ? : run {
156
- val intent = Intent (this , this ::class .java).setAction(ACTION_STOP_TRACKING )
157
- intent.putExtra(GPS_SERVICE_NOTIFICATION , ACTION_STOP_TRACKING )
158
- PendingIntent .getService(
159
- this ,
160
- 0 ,
161
- intent,
162
- PendingIntent .FLAG_UPDATE_CURRENT or PendingIntent .FLAG_IMMUTABLE
163
- )
164
154
}
155
+ /*
156
+ packageManager.getLaunchIntentForPackage(this.packageName)?.let { intent ->
157
+ intent.putExtra(GPS_SERVICE_NOTIFICATION, ACTION_STOP_TRACKING)
158
+ PendingIntent.getActivity(
159
+ this,
160
+ 0,
161
+ intent,
162
+ PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
163
+ )
164
+ } ?: run {
165
+ val intent = Intent(this, this::class.java).setAction(ACTION_STOP_TRACKING)
166
+ intent.putExtra(GPS_SERVICE_NOTIFICATION, ACTION_STOP_TRACKING)
167
+ PendingIntent.getService(
168
+ this,
169
+ 0,
170
+ intent,
171
+ PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
172
+ )
173
+ }
174
+ */
165
175
166
176
167
177
/*
@@ -173,7 +183,6 @@ class GPSUpdatesForegroundService : LifecycleService() {
173
183
)
174
184
*/
175
185
builder
176
- .setContentTitle(notificationContentTitle)
177
186
.setContentIntent(pendingIntent)
178
187
.setSmallIcon(
179
188
if (useApplicationNotificationSmallIcon)
@@ -187,6 +196,11 @@ class GPSUpdatesForegroundService : LifecycleService() {
187
196
.setVisibility(NotificationCompat .VISIBILITY_PRIVATE )
188
197
.setTicker(null )
189
198
199
+ notificationContentTitle?.let {
200
+ if (it.isNotEmpty())
201
+ builder.setContentTitle(notificationContentTitle)
202
+ }
203
+
190
204
val message = notificationContent ? : run {
191
205
val pm = getSystemService(POWER_SERVICE ) as PowerManager
192
206
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
@@ -200,7 +214,7 @@ class GPSUpdatesForegroundService : LifecycleService() {
200
214
resources.getString(R .string.gps_in_background)
201
215
}
202
216
}
203
- if (message.isNotEmpty() ) {
217
+ if (message.isNotEmpty()) {
204
218
builder.setStyle(NotificationCompat .BigTextStyle ().bigText(message))
205
219
}
206
220
return builder
@@ -230,7 +244,7 @@ class GPSUpdatesForegroundService : LifecycleService() {
230
244
}
231
245
232
246
@JvmStatic
233
- var notificationContentTitle = " S4Y GPS Demo "
247
+ var notificationContentTitle: String? = null
234
248
235
249
@JvmStatic
236
250
var notificationContent: String? = null
0 commit comments