Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-dagger/02d2bdb99905c196897e605676419b3b to your computer and use it in GitHub Desktop.
Save the-dagger/02d2bdb99905c196897e605676419b3b to your computer and use it in GitHub Desktop.
private fun showNotification(channelID: String) {
val stopSelf = Intent(this, CopieService::class.java)
stopSelf.putExtra(INTENT_EXTRA, true)
val startApp = Intent(this, MainActivity::class.java)
val stopPendingIntent = PendingIntent.getService(this, 0, stopSelf, FLAG_CANCEL_CURRENT)
val openAppPendingIntent = PendingIntent.getActivity(this, 0, startApp, FLAG_CANCEL_CURRENT)
startForeground(1995, NotificationCompat.Builder(this, channelID)
.setSmallIcon(R.drawable.ic_paste)
.setContentTitle("Copie is online")
.setContentText("Touch to open")
.setPriority(PRIORITY_MIN)
.setContentIntent(openAppPendingIntent)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.addAction(R.drawable.ic_stop, "Stop", stopPendingIntent)
.build())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment