Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Android 7.1 static app-shortcuts creator put extras into the intent?

This is a short question:

Android Nougat 7.1 has a new feature for launchers, to create app-shortcuts by showing a menu to choose from them: https://developer.android.com/about/versions/nougat/android-7.1.html https://developer.android.com/guide/topics/ui/shortcuts.html

From what I see, if you use dynamic ones, you can put anything you wish into them, but can static shortcuts (those that are pre-determined via XML) have extras in them? Meaning: can I put, for example, a string in the bundle of the intent of shortcuts ? Or can I only choose which action each of them will have?

I ask this because I don't see it mentioned there.

like image 786
android developer Avatar asked Dec 15 '22 01:12

android developer


1 Answers

Yes, as per R.styleable#Intent:

Declaration of an Intent object in XML. May also include zero or more <categories> and <extra> tags.

Parsing the Intent can be seen in the Intent.parseIntent source code, where you'll see it parses the extra tags with Resources.parseBundleExtra(), which supports Strings, booleans, integers, and floats.

<intent android:action="YOUR_ACTION" >
     <extra android:name="extra_name" android:value="extra_value" />
</intent>
like image 61
ianhanniballake Avatar answered May 19 '23 01:05

ianhanniballake