how to add app button next to flashlight on home screen dropdown

25 views Asked by At

I would like to add button on the dropdown on the home screen so that I can start it without logging in or quickly access it if I'm logged in. This would be in the dropdown that contains flashlight and Blu Tooth. Pressing the button would load QR code (or my own QR code reader) I want to create very fast access so I don't have to go searching through all my buttons to find it or maybe even not log in.

Is there a way to add this programmatically? That is when the APK is installed, it knows to locate itself on this dropdown.

1

There are 1 answers

0
Kevin Coppock On

This is the Quick Settings Tile API. You can use the TileService class for this, and define it in your manifest:

class QuickSettingsTileService : TileService() {
  override fun onTileAdded() {
    // Initialize tile state (text, icons, etc.)
  }

  override fun onTileClicked() {
    // Handle click
  }

  // More lifecycle methods available.
}
 <service
   android:name=".QuickSettingsTileService"
   android:exported="true"
   android:label="@string/tile_label"  // 18-character limit.
   android:icon="@drawable/tile_icon"
   android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
   <intent-filter>
     <action android:name="android.service.quicksettings.action.QS_TILE" />
   </intent-filter>
 </service>

More documentation here.