Skip to content

Commit 891bc86

Browse files
committed
3.0.0-alpha2 - launch application on notification click
1 parent 4000f24 commit 891bc86

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

gps-android/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ publishing {
5959
create<MavenPublication>("Release") {
6060
groupId = "solutions.s4y.gps"
6161
artifactId = "gps-sdk-android"
62-
version = "3.0.0-alpha1"
62+
version = "3.0.0-alpha2"
6363

6464
pom {
6565
packaging = "aar"

gps-android/src/main/java/s4y/gps/sdk/android/GPSUpdatesForegroundService.kt

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,33 @@ class GPSUpdatesForegroundService : LifecycleService() {
145145
private fun defaultNotificationBuilder(builder: NotificationCompat.Builder): NotificationCompat.Builder {
146146
val pendingIntent =
147147
packageManager.getLaunchIntentForPackage(this.packageName)?.let { intent ->
148-
intent.putExtra(GPS_SERVICE_NOTIFICATION, ACTION_STOP_TRACKING)
149148
PendingIntent.getActivity(
150149
this,
151150
0,
152151
intent,
153152
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
154153
)
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-
)
164154
}
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+
*/
165175

166176

167177
/*
@@ -173,7 +183,6 @@ class GPSUpdatesForegroundService : LifecycleService() {
173183
)
174184
*/
175185
builder
176-
.setContentTitle(notificationContentTitle)
177186
.setContentIntent(pendingIntent)
178187
.setSmallIcon(
179188
if (useApplicationNotificationSmallIcon)
@@ -187,6 +196,11 @@ class GPSUpdatesForegroundService : LifecycleService() {
187196
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
188197
.setTicker(null)
189198

199+
notificationContentTitle?.let {
200+
if (it.isNotEmpty())
201+
builder.setContentTitle(notificationContentTitle)
202+
}
203+
190204
val message = notificationContent ?: run {
191205
val pm = getSystemService(POWER_SERVICE) as PowerManager
192206
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -200,7 +214,7 @@ class GPSUpdatesForegroundService : LifecycleService() {
200214
resources.getString(R.string.gps_in_background)
201215
}
202216
}
203-
if (message.isNotEmpty() ) {
217+
if (message.isNotEmpty()) {
204218
builder.setStyle(NotificationCompat.BigTextStyle().bigText(message))
205219
}
206220
return builder
@@ -230,7 +244,7 @@ class GPSUpdatesForegroundService : LifecycleService() {
230244
}
231245

232246
@JvmStatic
233-
var notificationContentTitle = "S4Y GPS Demo"
247+
var notificationContentTitle: String? = null
234248

235249
@JvmStatic
236250
var notificationContent: String? = null

0 commit comments

Comments
 (0)