Skip to content

Commit

Permalink
Migrate to TileServiceCompat
Browse files Browse the repository at this point in the history
  • Loading branch information
G00fY2 committed May 4, 2024
1 parent f129b25 commit 1564f14
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package io.github.g00fy2.quickiesample.quicksettingstile

import android.app.PendingIntent
import android.content.ComponentName
import android.content.Intent
import android.os.Build
import android.os.IBinder
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi
import androidx.core.service.quicksettings.PendingIntentActivityWrapper
import androidx.core.service.quicksettings.TileServiceCompat
import io.github.g00fy2.quickiesample.MainActivity

// optional service to allow launching the sample app from the quick settings
Expand All @@ -28,12 +31,15 @@ class QuickieTileService : TileService() {

override fun onClick() {
super.onClick()
@Suppress("DEPRECATION")
startActivityAndCollapse(
Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
putExtra(MainActivity.OPEN_SCANNER, true)
}

val intent = Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
putExtra(MainActivity.OPEN_SCANNER, true)
}

TileServiceCompat.startActivityAndCollapse(
this,
PendingIntentActivityWrapper(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT, true)
)
}
}

0 comments on commit 1564f14

Please sign in to comment.