Create a key in the shortcuts pane

Hello, I would like to know if it is possible to create keys in the shortcut menu in AI2. To be clear, the shortcut menu is this:


So I was just wondering if it was possible to do this!

Thanks in advance,
Nico

I asked Gemini and this was the answer, see below

Tldr: it is not possible

That's an interesting question! While Android allows users to create shortcuts on their home screen, programmatically creating icons directly in the shortcuts pane (which I understand to be the quick settings panel you access by swiping down from the top) is not a standard or officially supported Android development feature for regular apps.
Here's a breakdown of why and what alternatives exist:
Why it's not directly supported:

  • System-Level Control: The quick settings panel is a system-level UI component managed by the Android operating system. Modifying it programmatically without explicit system permissions would be a security and stability risk.
  • User Experience Consistency: Android aims for a consistent user experience. Allowing arbitrary apps to inject icons into the quick settings panel could lead to a cluttered and unpredictable interface.
  • Permissions and Security: Granting apps the permission to directly modify system UI elements would raise significant security concerns.
    What you can do (Alternatives and Related Concepts):
  • Home Screen Shortcuts: You can programmatically create shortcuts on the user's home screen. This is a well-supported feature using the ACTION_CREATE_SHORTCUT intent. This allows users to quickly access specific actions within your app.
    Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
    shortcutIntent.setClass(context, YourActivity.class); // Replace YourActivity
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

Intent addIntent = new Intent();
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "My App Action"); // Shortcut title
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(context, R.mipmap.ic_launcher)); // Shortcut icon

context.sendBroadcast(addIntent);

  • App Widgets: App widgets provide a more persistent way to display information and offer interactive elements directly on the home screen. While not in the shortcuts pane, they offer a visible and accessible way for users to interact with your app's functionality.
  • Quick Settings Tiles (for System Apps/Privileged Apps): Android does have a mechanism for adding tiles to the quick settings panel. However, this is generally reserved for system apps or apps with special system-level privileges. Regular third-party apps cannot typically add tiles directly.
  • Notifications with Quick Actions: While not icons directly in the shortcuts pane, you can create notifications that include action buttons. These buttons appear below the notification content and can provide quick access to specific functions within your app.
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
    .setSmallIcon(R.drawable.notification_icon)
    .setContentTitle("My App")
    .setContentText("Do something quickly!")
    .setPriority(NotificationCompat.PRIORITY_DEFAULT);

Intent actionIntent = new Intent(context, YourActionReceiver.class); // Replace YourActionReceiver
PendingIntent actionPendingIntent =
PendingIntent.getBroadcast(context, 0, actionIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.addAction(R.drawable.ic_quick_action, "Quick Action", actionPendingIntent);

NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(notificationId, builder.build());

In summary, directly adding custom icons to the Android quick settings panel programmatically from a regular app is not a supported feature due to system-level restrictions and security considerations. You should explore alternative approaches like home screen shortcuts, app widgets, or notifications with quick actions to provide quick access to your app's functionality.
Could you tell me more about what specific functionality you were hoping to make quickly accessible? Knowing your use case might help me suggest the most suitable alternative.

Taifun

Thank you for this very comprehensive answer! I am disappointed that I cannot do what I wanted, but thank you anyway!

Nico