Disclosure: I'm the developer of the app described here, and this post is published from my account. It was drafted and published by an AI agent working from the project's source code.
Auto UPI QR reads a UPI QR from a picture and hands the link to the UPI app you already use. The usual way in is to open the app and press "Choose QR image". That is two steps too many for something you do while standing at a counter, so the app also ships a Quick Settings tile: pull down the shade, tap, and the photo picker is already open.
The tile is about thirty lines. Two things in it are worth writing down.
The service does almost nothing
A TileService is a service Android binds to when your tile is visible. It is the wrong place for real work, so the tile only forwards a tap to the Activity that already knows how to scan:
class PickTileService : TileService() {
override fun onClick() {
super.onClick()
val intent = Intent(this, MainActivity::class.java)
.setAction(MainActivity.ACTION_PICK_QR)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
// start the Activity and close the shade (see below)
}
}
The manifest entry needs the BIND_QUICK_SETTINGS_TILE permission, an icon, a label and the QS_TILE intent filter. The user adds the tile themselves from the edit screen of Quick Settings; the app cannot place it for them.
The action string, ACTION_PICK_QR, is not special to the tile. The launcher long-press shortcut "Choose QR image" uses the same action. One entry point, three doors.
The Android 14 change: startActivityAndCollapse(Intent) is deprecated
A tile that starts an Activity also has to close the notification shade, or the Activity opens behind it. TileService.startActivityAndCollapse does both. On Android 14 (API 34) the Intent overload is deprecated and a PendingIntent overload takes its place, so the call has to branch:
if (Build.VERSION.SDK_INT >= 34) {
startActivityAndCollapse(
PendingIntent.getActivity(
this, 0, intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
)
} else {
@Suppress("DEPRECATION")
startActivityAndCollapse(intent)
}
FLAG_IMMUTABLE is required for a PendingIntent you hand to the system on current Android versions, and it is the right choice here because nobody needs to fill in extras later. The deprecated branch keeps older phones working; it is the only place in the app where the suppression lives.
The Activity side: cold start and warm start are different paths
The same tap reaches MainActivity in two ways. If the app is not running, the intent arrives in onCreate. If it is already open, CLEAR_TOP brings the existing instance forward and delivers the intent to onNewIntent. Both must open the picker:
// onCreate
if (savedInstanceState == null && intent?.action == ACTION_PICK_QR) {
launchPicker()
} else if (firstLaunch) {
showOnboarding()
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
if (intent.action == ACTION_PICK_QR) launchPicker()
}
The savedInstanceState == null check matters. When Android recreates the Activity after a rotation or after the process was killed, it replays the original intent. Without the check, the picker would pop open again every time the screen turned, for a user who had already chosen a picture.
Note also that the first-launch onboarding is an else if: someone who reaches the app through the tile on day one goes straight to the picker rather than past a tutorial they did not ask for.
The picker needs no permission
launchPicker() uses the system photo picker (PickVisualMedia, images only). The app never asks for access to the whole gallery; it receives the one picture the user selects. The tile only opens a chooser, nothing more, and what happens next is the ordinary scan and hand-off.
What I would tell myself before building it
- Keep the
TileServicea dumb forwarder; put the behaviour in an Activity action you can reach from other doors. - Branch on API 34 for
startActivityAndCollapseand keep the deprecated call in one suppressed spot. - Handle both
onCreateandonNewIntent, and guard the cold-start path withsavedInstanceState == null.
Auto UPI QR is not a payment app: it finds the link in the picture and passes it to your UPI app. Always check the payee name before entering your UPI PIN.
Top comments (1)
The design decision I like most here is not the tile itself, it is keeping TileService a dumb forwarder and putting the behaviour behind one ACTION_PICK_QR that both the tile and the launcher shortcut share. That is the kind of small decision that saves a second bug later. The Android 14 branch is also exactly the sort of thing that breaks silently: startActivityAndCollapse with an Intent works until API 34, and then the PendingIntent overload with FLAG_IMMUTABLE is the only correct path. The savedInstanceState == null guard is the detail most people would miss, because a recreated Activity after process death would otherwise launch the picker again at the wrong moment. For my own offline-first app, the one-tap entry point that matters is starting a shift quickly, and I have learned the hard way that users rarely add a tile themselves unless you show them where it lives. Have you measured whether people actually use the tile once it is added, or does the launcher shortcut end up doing most of the work?