Android

Android

API 26 and up, androidx.core 1.17.

Configuration

QuickActions.androidConfig =
    AndroidQuickActionsConfig(
        defaultIconRes = R.drawable.ic_bolt,                       // 0 → application icon
        iconResolver = { key -> if (key == "timer") R.drawable.ic_timer else 0 },
        targetActivity = null,                                     // null → launcher Activity
        intentFlags = FLAG_ACTIVITY_NEW_TASK or FLAG_ACTIVITY_CLEAR_TOP or FLAG_ACTIVITY_SINGLE_TOP,
        intentBuilder = null,                                      // full control; action + extra still added
    )

Set it before the first manager is created. Icons resolve through iconResolver at compile time, never by resource name, so shrunk release builds keep working.

Delivery

Every shortcut opens the target Activity with QuickActions.ACTION and the encoded action in QuickActions.EXTRA_ACTION.

  • Compose: rememberQuickActionsManager() calls QuickActions.attach(activity) for you.
  • ComponentActivity: call QuickActions.attach(this) once in onCreate.
  • Plain Activity: QuickActions.handleLaunchIntent(intent, savedInstanceState) in onCreate and QuickActions.handleNewIntent(intent) in onNewIntent.

attach dispatches the launch intent once per Activity lifetime (a saved-state flag survives rotation and process restore), ignores relaunches from Recents (FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY), listens for onNewIntent until ON_DESTROY, and drops launches whose id is not a shortcut the platform knows for your app, so am start with a forged extra never reaches launches.

Static shortcuts

Entries in shortcuts.xml are delivered too when their intent uses QuickActions.ACTION and carries the action JSON:

<intent
    android:action="io.github.androidpoet.quickactions.action.QUICK_ACTION"
    android:targetPackage="com.example.app"
    android:targetClass="com.example.app.MainActivity">
    <extra android:name="io.github.androidpoet.quickactions.extra.ACTION" android:value='{"id":"about","title":"About"}' />
</intent>

Static items count against maxActions.

Extras

AndroidQuickActionsManager adds isRateLimited (the system refuses changes from a backgrounded app), canPin and requestPin(id). Pinned copies keep the label and payload from publish time.