Android Intent
Android Intent
Activity 2
PASSWORD
**********
Go to Next Activity
Login
<application>
<activity android:name=".MyActivity" />
</application>
Action Name
Data
Structure
of an Intent Category
Extra Flags
INTENT TYPES
IMPLICIT
EXPLICIT
Used to control the execution flow between Activities belonging to the same Android
application.
startActivity(intent);
ComponentName component=new
ComponentName(this,SecondActivity.class);
intent.setComponent(component);
startActivity(intent);
Programming with Android 196
Intent types: Explicit Intents
intent.putExtra(“KEY”, VALUE);
Set an argument named “MyValue” and equal to 5.
intent.getExtras().getTYPE(“KEY”);
intent.getExtras().getInt(“myValue”);
intent.getExtras().getString(“myString”);
intent.getExtras().getBoolean(“myBoolean”);
Programming with Android 198
Intent types: Explicit Intents
INTENT TYPES
EXPLICIT IMPLICIT
ACTION_MAIN Start as a main entry point, does not expect to receive data.
ACTION_PICK Pick an item from the data, returning what was selected.
startActivity(intent);
scheme://host:port/path
tel:003-232-134-126 EXAMPLEs
content://contacts/people/1
http://www.ensa.uh1.ac.ma
Programming with Android 210
Intent types: Implicit Intents
intent.setData(Uri.parse("tel:0123456789"));
startActivity(intent);
Programming with Android 211
Intent types: Implicit Intents
intent.setData(Uri.parse("content://contacts/people/1"));
startActivity(intent);
Programming with Android 212
Intent types: Implicit Intents
intent.setData(Uri.parse(”http://www.ensa.uh1.ac.ma"));
startActivity(intent);
Programming with Android 213
Intent types: Implicit Intents
type/subtype
EXAMPLEs
startActivity(intent);
Programming with Android 218
Intent types: Intent Resolution
<intent-filter>
<action android:name=”ACTION_ECHO” />
</intent-filter>
<intent-filer … >
<action android:name=“com.example.ma.ECHO”/>
</intent-filter>
Programming with Android 221
Intent types: Intent Resolution
<intent-filer … >
<data android:mimeType=“audio/* android:scheme=“http”/>
<data android:mimeType=“video/mpeg android:scheme=“http”/>
</intent-filter>