what are intent extras

what is openintents.org

In a web application in response to an action such as a button click, one might want to transfer the user to a new page or a screen. This is done typically done through a URL.

A url has an action to invoke and a set of parameters to resolve the data to display.

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.

startActivity
broadcastintent
startservice
bindservice
action constant
data uri
category
type
component
extras

type

type is the explicit type of data. give an example of how to use this

type seems to be only MIME type

where as a Component may be class name

extras is a bundle of information where bundle is a class

How many mime types are there?

How many categories are there?

There are two kinds of intents: Implicit and Explicit

what are components and how are they different from classes?

Intent resolution is how the system matches up an intent or an event with its target like say an activity. It uses "action", "type", "scheme", and "categories" of the incoming intent.

See if this article throws some light on this

api reference

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:

The action, if given, must be listed by the component as one it handles.

The type is retrieved from the Intent's data, if not already supplied in the Intent. Like the action, if a type is included in the intent (either explicitly or implicitly in its data), then this must be listed by the component as one it handles.

For data that is not a content: URI and where no explicit type is included in the Intent, instead the scheme of the intent data (such as http: or mailto:) is considered. Again like the action, if we are matching a scheme it must be listed by the component as one it can handle.

The categories, if supplied, must all be listed by the activity as categories it handles. That is, if you include the categories CATEGORY_LAUNCHER and CATEGORY_ALTERNATIVE, then you will only resolve to components with an intent that lists both of those categories. Activities will very often need to support the CATEGORY_DEFAULT so that they can be found by Context.startActivity().


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.notepad">
     <application android:icon="@drawable/app_notes"
             android:label="@string/app_name">

         <provider class=".NotePadProvider"
                 android:authorities="com.google.provider.NotePad" />

         <activity class=".NotesList" android:label="@string/title_notes_list">
             <intent-filter>
                 <action android:value="android.intent.action.MAIN" />
                 <category android:value="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
                 <action android:value="android.intent.action.VIEW" />
                 <action android:value="android.intent.action.EDIT" />
                 <action android:value="android.intent.action.PICK" />
                 <category android:value="android.intent.category.DEFAULT" />
                 <type android:value="vnd.android.cursor.dir/vnd.google.note" />
             </intent-filter>
             <intent-filter>
                 <action android:value="android.intent.action.GET_CONTENT" />
                 <category android:value="android.intent.category.DEFAULT" />
                 <type android:value="vnd.android.cursor.item/vnd.google.note" />
             </intent-filter>
         </activity>

         <activity class=".NoteEditor" android:label="@string/title_note">
             <intent-filter android:label="@string/resolve_edit">
                 <action android:value="android.intent.action.VIEW" />
                 <action android:value="android.intent.action.EDIT" />
                 <category android:value="android.intent.category.DEFAULT" />
                 <type android:value="vnd.android.cursor.item/vnd.google.note" />
             </intent-filter>

             <intent-filter>
                 <action android:value="android.intent.action.INSERT" />
                 <category android:value="android.intent.category.DEFAULT" />
                 <type android:value="vnd.android.cursor.dir/vnd.google.note" />
             </intent-filter>

         </activity>

         <activity class=".TitleEditor" android:label="@string/title_edit_title"
                 android:theme="@android:style/Theme.Dialog">
             <intent-filter android:label="@string/resolve_title">
                 <action android:value="com.android.notepad.action.EDIT_TITLE" />
                 <category android:value="android.intent.category.DEFAULT" />
                 <category android:value="android.intent.category.ALTERNATIVE" />
                 <category android:value="android.intent.category.SELECTED_ALTERNATIVE" />
                 <type android:value="vnd.android.cursor.item/vnd.google.note" />
             </intent-filter>
         </activity>

     </application>
 </manifest>

I need more information on default category

Typically an intent would have mentioned the action, might have mentioned the category, and also a type (but more likely data).

It is the provider satisfying the data uri that gives out the mime type. Based on this mime type an intent filter is picked up.

So data is really an input to an intent filter but won't be needed for describing the intent.

Does an activity have to do something special based on action it supports.

For example for a PICK action, does the activity need to write a call back for that action and do somethign differently?

DEFAULT means that this action can be considered a default action for the type of data specified - i.e. something requesting the default action for a particular data item can get sent straight to this intent. It's like saying "I know this one, let me handle it"

ALTERNATIVE means that this can act as one of the alternatives that the user can select to handle a particular request or item. If there are several alternatives, the user will (or may) be prompted as to which one to use.

SELECTED_ALTERNATIVE means that the action applies to something the user currently has selected.

These are used for adding menu items to other applications of new actions your own application can perform on the data being shown by the other app.

what is urimatcher and why would one use it and how to use it?

It is possible that this data can be open ended. But is it? Yes and no. It is not because the method "getData" from an intent returns a "uri". Which means irrespective of the data an intent wants to carry with it it takes the form of a "uri". A uri is like a http url. So the receiver must call the url to open the stream to receive data. Or you can use additional arguments from the url. Because the provider of that url can provide any data structure back the answer is also yes. In addition the intent carries another "fixed" data object called a Bundle which is a collection key value pairs.

How does a receiver retrieve data from a an intent or a uri to be specific?

How does the receiver of an intent know the mime type of the data?

How does the intent resolver know the mime type of an intents data?

What is ContentResolver?

Search for: What is ContentResolver?

String getType(uri): returns mime type of the uri

How does ContentResolver know the mime type of a uri?

Search for: How does ContentResolver know the mime type of a uri?

It is important you read ContentProvider

How do you locate a provider based on android content uri

Search for: How do you locate a provider based on android content uri

Read about content providers

Search for: provider android content url structure

The above is an excellent article

You can find a list of intents here

where can I find the various android provider URIs listed?

Search for: where can I find the various android provider URIs listed?

Where can I find android constants for permissions

Search for: Where can I find android constants for permissions

On Content URIs

A list of uris can be found here

A relevent discussion on content providers

Android Parcel, JSON, Serialize, binding

Search for: Android Parcel, JSON, Serialize, binding


private void dialWithNumber(String tel)
    {
    	String  telUriString = "tel:" + tel;
    	Intent intent = new Intent(Intent.ACTION_DIAL);
    	intent.setData(Uri.parse(telUriString));
    	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    	this.startActivity(intent);
    }

private void invokeWebBrowser()
    {
    	this.appendText("Invoke Browser invoked");
    	Intent intent = new Intent(Intent.ACTION_VIEW);
    	intent.setData(Uri.parse("http://www.google.com"));
    	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    	this.startActivity(intent);
    }

How does android know what activity to invoke based on a uri?

Search for: How does android know what activity to invoke based on a uri?

deliverNewIntents activitythread.java

Search for: deliverNewIntents activitythread.java

IntentFilter

xml representation for intent filter

data tag of an intent filter


<intent-filter>
   <action android:name="android.intent.action.VIEW" />
   <action android:name="android.intent.action.EDIT" />
   <action android:name="android.intent.action.PICK" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
</intent-filter>

is there a default behavior for setFlags in Android?gquestion

is there a default behavior for setFlags in Android?

Search for: is there a default behavior for setFlags in Android?

search the developers group

Read this on tasks

An important discussion to follow on the activity invocation

How do android permissions work?

Search for: How do android permissions work?

Makesure you read through the following IBinder doc


Bundle
Parcelable
Parcel
IBinder

You need to understand searchmanager

A discussion on the DEFAULT category

exercise content provided intents

How to replace the home page

A nice thread about internals do read

Search for home category

How to start multiple activities

Search for multiple activities

Use notepad intents to test

Read about startActivityWithResult

Photopicker

onActivityResult api

setResult api

sample code and usage for starting activites and getting results

My items on android developers group

Sorry this is the right link

Read about get_content

Read about action_chooser

understanding get_content


extra names
actions
flags

public static void invokePick(Activity activity)
{
  Intent pickIntent = new Intent(Intent.ACTION_PICK);
  //pickIntent.setData(Contacts.CONTENT_URI);
  pickIntent.setData(Uri.parse(
     "content://com.google.provider.NotePad/notes"));
  activity.startActivityForResult(pickIntent, 1);
}

public static void parseResult(HelloWorldActivity activity
	, int requestCode
	, int resultCode
	, Intent outputIntent)
{
	activity.appendText("parseResult called");
	if (requestCode != 1)
	{
	activity.appendText("Some one else called this. not me");
			return;
	}
	if (resultCode != Activity.RESULT_OK)
	{
		activity.appendText("Result code is not ok:" + resultCode);
		return;
	}
	activity.appendText("Result code is ok:" + resultCode);
	activity.appendText("The output uri:");
	activity.appendText(outputIntent.getData().toString());
}

protected void onActivityResult(int requestCode
	,int resultCode
	,Intent outputIntent)
{
super.onActivityResult(requestCode, resultCode, outputIntent);
IntentsUtils.parseResult(this, requestCode, resultCode, outputIntent);
}

What is an Android chooser?

Search Google for: What is an Android chooser?

Search Android Developers Group for: What is an Android chooser?

Search Android Beginers Group for: What is an Android chooser?

Search Google Code for: What is an Android chooser?

Search Android Issues Database for: What is an Android chooser?

Android createChooser

Search Google for: Android createChooser

Search Android Developers Group for: Android createChooser

Search Android Beginers Group for: Android createChooser

Search Google Code for: Android createChooser

Search Android Issues Database for: Android createChooser


public static void invokeGetContent(Activity activity)
    {
      Intent pickIntent = new Intent(Intent.ACTION_GET_CONTENT);
      pickIntent.setType("vnd.android.cursor.item/vnd.google.note");
      activity.startActivityForResult(pickIntent, 2);
    }

Read this code and see what it does

Openintents.org is now at code.google.com/p/openintents