Best code examples for Intent toUri method (android.content.Intent.toUri)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Intent toUri method.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Intent toUri examples from Open Source projects
This code example shows how to use the following methods: getParcelableExtra, putExtra, resolveActivityInfo, toUri
108:	Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); 
-
110:	intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME)); 
111:	String appUri = intent.toUri(0); 
-
118:	ActivityInfo ai = intent.resolveActivityInfo(pm, PackageManager.GET_ACTIVITIES); 
-
128:	return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0); 
-
138:	return name != null ? name : intent.toUri(0); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getStringExtra, resolveActivityInfo, toUri
154:	ActivityInfo ai = intent.resolveActivityInfo(pm, PackageManager.GET_ACTIVITIES); 
-
164:	return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0); 
-
169:	String name = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); 
-
174:	return name != null ? name : intent.toUri(0); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: addFlags, setPackage, toUri
167:	Intent intent = new Intent(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); 
168:	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
169:	intent.setPackage(getEngineName()); 
-
171:	Log.v(TAG, "Installing voice data: " + intent.toUri(0)); 
172:	startActivity(intent); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: toUri
152:	Log.i(TAG, "Launching intent: " + intent.toUri(0)); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getStringExtra, resolveActivityInfo, toUri
121:	ActivityInfo ai = intent.resolveActivityInfo(pm, PackageManager.GET_ACTIVITIES); 
-
131:	return (friendlyName != null) ? friendlyName : intent.toUri(0); 
-
136:	String name = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); 
-
141:	return name != null ? name : intent.toUri(0); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getIcon, getItemCount
142:	Bitmap icon = mClipping.getIcon(); 
-
147:	if (mClipping.getItemCount() > 0) { 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
47:	targetClipData = new ClipData(null, mimeTypes, item); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getItemAt
65:	ClipData.Item item=clip.getItemAt(0); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getIcon, getItemCount
142:	setVisibility(View.VISIBLE); 
-
147:	} else { 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getItemAt, getItemCount
27:	if (cp.getItemCount() > 0) { 
28:	Item cpi = cp.getItemAt(0); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getItemAt
75:	ClipData.Item item=clip.getItemAt(0); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getIcon, getItemCount
143:	Bitmap icon = mClipping.getIcon(); 
-
148:	if (mClipping.getItemCount() > 0) { 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getItemAt
34:	return hasText(context) ? clip.getItemAt(0).coerceToText(context) : null; 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getItemAt, getItemCount
69:	if (clip != null && clip.getItemCount() > 0) { 
70:	final CharSequence sequence = clip.getItemAt(0).coerceToText(mContext); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getItemAt
102:	ClipData.Item item = clip.getItemAt(0); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getItemAt
102:	ClipData.Item item = clip.getItemAt(0); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getItemAt, getItemCount
61:	if (cp.getItemCount() > 0) 
-
63:	Item cpi = cp.getItemAt(0); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getItemAt
136:	clipData = (String) clip.getItemAt(0).getText(); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: getItemAt
110:	ClipData.Item item = clip.getItemAt(0); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: getItemAt
73:	+ data.getItemAt(0).getText()); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods:
149:	ClipData clipData = new ClipData((CharSequence) v.getTag(), mimeType, item); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getItemAt
68:	Log.v(DROPTAG, "Item data is " + data.getItemAt(0).getText()); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: getDescription, getItemAt
175:	if (data.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { 
176:	ClipData.Item item = data.getItemAt(0); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: getItemAt, getItemCount
111:	if (clip.getItemCount() > 0) { 
112:	inpURL.setText(clip.getItemAt(0).getText()); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods:
47:	targetClipData = new ClipData(null, mimeTypes, item); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods:
57:	ClipData dragData = new ClipData((CharSequence) v.getTag(), 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods:
47:	targetClipData = new ClipData(null, mimeTypes, item); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods:
45:	ClipData dragData = new ClipData((CharSequence) v.getTag(), mimeTypes , item); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods:
31:	ClipData clip = new ClipData(text, new String[]{"text/plain"}, new ClipData.Item(text)); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods:
23:	ClipData dragData = new ClipData("GridViewItem", mimeTypes, item); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods:
42:	ClipData cd = new ClipData(new ClipDescription("text_data", mimeType), item); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods:
136:	ClipData clipData = new ClipData("hello", new String[] 
Full Snippet Info
4
CodeRank
Related Intent toUri Questions & Answers:
Intent Class Overview
An intent is an abstract description of an operation to be performed. It can be used with startActivity to launch an Activity, broadcastIntent to send it to any interested BroadcastReceiver components, and startService(Intent) or bindService(Intent, ServiceConnection, int) to communicate with a background Service.

An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.The primary pieces of information in an intent are:Some examples of action/data pairs are:In addition to these primary attributes, there are a number of secondary attributes that you can also include with an intent:Here are some examples of other operations you can specify as intents using these additional parameters:There are a variety of standard Intent action and category constants defined in the Intent class, but applications can also define their own. These strings use java style scoping, to ensure they are unique -- for example, the standard ACTION_VIEW is called "android.intent.action.VIEW".Put together, the set of actions, data types, categories, and extra data defines a language for the system allowing for the expression of phrases such as "call john smith's cell". As applications are added to the system, they can extend this language by adding new actions, types, and categories, or they can modify the behavior of existing phrases by supplying their own activities that handle them.There are two primary forms of intents you will use. Explicit Intents have specified a component (via setComponent(ComponentName) or setClass(Context, Class)), which provides the exact class to be run. Often these will not include any other information, simply being a way for an application to launch various internal activities it has as the user interacts with the application. Implicit Intents have not specified a component; instead, they must include enough information for the system to determine which of the available components is best to run for that intent. When using implicit intents, given such an arbitrary intent we need to know what to do with it. This is handled by the process of Intent resolution, which maps an Intent to an Activity, BroadcastReceiver, or Service (or sometimes two or more activities/receivers) that can handle it.The intent resolution mechanism basically revolves around matching an Intent against all of the descriptions in the installed application packages. (Plus, in the case of broadcasts, any BroadcastReceiver objects explicitly registered with registerReceiver(BroadcastReceiver, IntentFilter).) More details on this can be found in the documentation on the IntentFilter class.There are three pieces of information in the Intent that are used for resolution: the action, type, and category. Using this information, a query is done on the PackageManager for a component that can handle the intent. The appropriate component is determined based on the intent information supplied in the AndroidManifest.xml file as follows:For example, consider the Note Pad sample application that allows user to browse through a list of notes data and view details about individual items. Text in italics indicate places were you would replace a name with one specific to your own package.The first activity, com.android.notepad.NotesList, serves as our main entry into the app. It can do three things as described by its three intent templates: This provides a top-level entry into the NotePad application: the standard MAIN action is a main entry point (not requiring any other information in the Intent), and the LAUNCHER category says that this entry point should be listed in the application launcher. This declares the things that the activity can do on a directory of notes. The type being supported is given with the tag, where vnd.android.cursor.dir/vnd.google.note is a URI from which a Cursor of zero or more items (vnd.android.cursor.dir) can be retrieved which holds our note pad data (vnd.google.note). The activity allows the user to view or edit the directory of data (via the VIEW and EDIT actions), or to pick a particular note and return it to the caller (via the PICK action). Note also the DEFAULT category supplied here: this is required for the Context.startActivity method to resolve your activity when its component name is not explicitly specified. This filter describes the ability return to the caller a note selected by the user without needing to know where it came from. The data type vnd.android.cursor.item/vnd.google.note is a URI from which a Cursor of exactly one (vnd.android.cursor.item) item can be retrieved which contains our note pad data (vnd.google.note). The GET_CONTENT action is similar to the PICK action, where the activity will return to its caller a piece of data selected by the user. Here, however, the caller specifies the type of data they desire instead of the type of data the user will be picking from. Given these capabilities, the following intents will resolve to the NotesList activity:The second activity, com.android.notepad.NoteEditor, shows the user a single note entry and allows them to edit it. It can do two things as described by its two intent templates: The first, primary, purpose of this activity is to let the user interact with a single note, as decribed by the MIME type vnd.android.cursor.item/vnd.google.note. The activity can either VIEW a note or allow the user to EDIT it. Again we support the DEFAULT category to allow the activity to be launched without explicitly specifying its component. The secondary use of this activity is to insert a new note entry into an existing directory of notes. This is used when the user creates a new note: the INSERT action is executed on the directory of notes, causing this activity to run and have the user create the new note data which it then adds to the content provider. Given these capabilities, the following intents will resolve to the NoteEditor activity:The last activity, com.android.notepad.TitleEditor, allows the user to edit the title of a note. This could be implemented as a class that the application directly invokes (by explicitly setting its component in the Intent), but here we show a way you can publish alternative operations on existing data:In the single intent template here, we have created our own private action called com.android.notepad.action.EDIT_TITLE which means to edit the title of a note. It must be invoked on a specific note (data type vnd.android.cursor.item/vnd.google.note) like the previous view and edit actions, but here displays and edits the title contained in the note data. In addition to supporting the default category as usual, our title editor also supports two other standard categories: ALTERNATIVE and SELECTED_ALTERNATIVE. Implementing these categories allows others to find the special action it provides without directly knowing about it, through the queryIntentActivityOptions(ComponentName, Intent[], Intent, int) method, or more often to build dynamic menu items with addIntentOptions(int, int, int, ComponentName, Intent[], Intent, int, MenuItem[]). Note that in the intent template here was also supply an explicit name for the template (via android:label="@string/resolve_title") to better control what the user sees when presented with this activity as an alternative action to the data they are viewing. Given these capabilities, the following intent will resolve to the TitleEditor activity:These are the current standard actions that Intent defines for launching activities (usually through startActivity(Intent). The most important, and by far most frequently used, are ACTION_MAIN and ACTION_EDIT. ACTION_MAIN ACTION_VIEW ACTION_ATTACH_DATA ACTION_EDIT ACTION_PICK ACTION_CHOOSER ACTION_GET_CONTENT ACTION_DIAL ACTION_CALL ACTION_SEND ACTION_SENDTO ACTION_ANSWER ACTION_INSERT ACTION_DELETE ACTION_RUN ACTION_SYNC ACTION_PICK_ACTIVITY ACTION_SEARCH ACTION_WEB_SEARCH ACTION_FACTORY_TEST Standard Broadcast Actions These are the current standard actions that Intent defines for receiving broadcasts (usually through registerReceiver(BroadcastReceiver, IntentFilter) or a tag in a manifest). ACTION_TIME_TICK ACTION_TIME_CHANGED ACTION_TIMEZONE_CHANGED ACTION_BOOT_COMPLETED ACTION_PACKAGE_ADDED ACTION_PACKAGE_CHANGED ACTION_PACKAGE_REMOVED ACTION_PACKAGE_RESTARTED ACTION_PACKAGE_DATA_CLEARED ACTION_UID_REMOVED ACTION_BATTERY_CHANGED ACTION_POWER_CONNECTED ACTION_POWER_DISCONNECTED ACTION_SHUTDOWN Standard Categories These are the current standard categories that can be used to further clarify an Intent via addCategory(String). CATEGORY_DEFAULT CATEGORY_BROWSABLE CATEGORY_TAB CATEGORY_ALTERNATIVE CATEGORY_SELECTED_ALTERNATIVE CATEGORY_LAUNCHER CATEGORY_INFO CATEGORY_HOME CATEGORY_PREFERENCE CATEGORY_TEST CATEGORY_CAR_DOCK CATEGORY_DESK_DOCK CATEGORY_LE_DESK_DOCK CATEGORY_HE_DESK_DOCK CATEGORY_CAR_MODE CATEGORY_APP_MARKET Standard Extra Data These are the current standard fields that can be used as extra data via putExtra(String, Bundle). EXTRA_ALARM_COUNT EXTRA_BCC EXTRA_CC EXTRA_CHANGED_COMPONENT_NAME EXTRA_DATA_REMOVED EXTRA_DOCK_STATE EXTRA_DOCK_STATE_HE_DESK EXTRA_DOCK_STATE_LE_DESK EXTRA_DOCK_STATE_CAR EXTRA_DOCK_STATE_DESK EXTRA_DOCK_STATE_UNDOCKED EXTRA_DONT_KILL_APP EXTRA_EMAIL EXTRA_INITIAL_INTENTS EXTRA_INTENT EXTRA_KEY_EVENT EXTRA_ORIGINATING_URI EXTRA_PHONE_NUMBER EXTRA_REFERRER EXTRA_REMOTE_INTENT_TOKEN EXTRA_REPLACING EXTRA_SHORTCUT_ICON EXTRA_SHORTCUT_ICON_RESOURCE EXTRA_SHORTCUT_INTENT EXTRA_STREAM EXTRA_SHORTCUT_NAME EXTRA_SUBJECT EXTRA_TEMPLATE EXTRA_TEXT EXTRA_TITLE EXTRA_UID Flags These are the possible flags that can be used in the Intent via setFlags(int) and addFlags(...
toUri Method Overview
Convert this Intent into a String holding a URI representation of it.
See Also
  • addFlags
    Add additional flags to the intent (or with existing flags value).
  • createChooser
    Convenience function for creating a ACTION_CHOOSER Intent.
  • filterEquals
    Determine if two intents are the same for the purposes of intent resolution (filtering).
  • getAction
    Retrieve the general action to be performed, such as ACTION_VIEW.
  • getComponent
    Retrieve the concrete component associated with the intent.
  • getData
    Retrieve data this intent is operating on.
  • getExtras
    Retrieves a map of extended data from the intent.
  • getFlags
    Retrieve any special flags associated with this intent.
  • getPackage
    Retrieve the application package name this Intent is limited to.
  • getType
    Retrieve any explicit MIME type included in the intent.
  • hasExtra
    Returns true if an extra value is associated with the given name.
  • putExtra
    Add extended data to the intent.
  • putExtras
    Copy all extras in 'src' in to this intent.
  • resolveActivityInfo
    Resolve the Intent into an ActivityInfo describing the activity that should execute the intent.
  • setAction
    Set the general action to be performed.
  • setClass
    Convenience for calling setComponent(ComponentName) with the name returned by a Class object.
  • setClassName
    Convenience for calling setComponent(ComponentName) with an explicit class name.
  • setComponent
    (Usually optional) Explicitly set the component to handle the intent.
  • setData
    Set the data this intent is operating on.
  • setDataAndType
    (Usually optional) Set the data for the intent along with an explicit MIME data type.
  • setFlags
    Set special flags controlling how this intent is handled.
  • setPackage
    (Usually optional) Set an explicit application package name that limits the components this Intent will resolve to.
  • setType
    Set an explicit MIME data type.
  • toURI
    This method was deprecated in API level 4. Use toUri(int) instead.