Close Quick Settings Panel after click the Quick Setting tile in android

1.1k views Asked by At

My app has a Tile Service.

After clicked on that tile, the onClick function run perfectly fine, but I wanted to close the quick setting panel, is there anyway to achive that goal?

QS panel image

3

There are 3 answers

1
DrHowdyDoo On BEST ANSWER

You can use startActivityAndCollapse instead of startActivity in your onClick function in TileService which will collapse the QS panel.

0
hiddeneyes02 On

Improvement to the right answer to resolve compatibility issue with old versions on Android:

Intent(this, DestinationActivity::class.java).also {
    it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
    TileServiceCompat.startActivityAndCollapse(
        this@MyTileService,
        PendingIntentActivityWrapper(
            this@MyTileService,
            0,
            it,
            PendingIntent.FLAG_UPDATE_CURRENT,
            true
        )
    )
}
0
G.Bhargav On

Just show dialog and dismiss it , if your query is just closing quick settings soon after pressing val dialog = Dialog(applicationContext) showDialog(dialog) dialog.dismiss()