Escolar Documentos
Profissional Documentos
Cultura Documentos
Tópicos Abordados
• Introdução às Intents
• Intents e Activities
• Dados de uma Intent
• Introdução aos Intent Filters
• Processo de Intent Resolution
• Actions nativas
• Categories nativas
Arquitetura do Android
Service Activity
BroadcastReceiver Activity
Intent
Android Core
BroadcastReceiver
1
O Que São Intents
Intents e as Activities
MyActivity1 MyActivity2
A activity não é
referenciada
explicitamente
2
Informações de uma Intent
Action Data
Intent
Category Extras
Intent: Action
Intent: Data
i.setType("application/ogg");
MIME type
3
Intent: Category
Intent: Extras
Colocando informações
Bundle b = new Bundle(); Intent i = new Intent();
b.putInt("code", 10); i.putExtra("code", 10);
b.putString("msg", "OK"); i.putExtra("msg", "OK");
Lendo informações
Bundle b = i.getExtras(); int c = i.getIntExtra("code", 0);
int c = b.getInt("code"); String m = i.getStringExtra("msg");
String m = b.getString("msg");
Intent Filters
Activity 1
Activity 2
Intent Android Core
Activity 3
Activity 4
4
Intent Filters
Elementos de um IntentFilter
Intent Resolution
5
Intent Resolution: Action
action = "ACTION1"
<intent-filter>
<action android:name="ACTION1" />
action = "ACTION5" <action android:name="ACTION2" />
</intent-filter>
action = ""
<intent-filter>
action = "ACTION1"
</intent-filter>
category = "CATEG1"
category = "CATEG2"
<intent-filter>
<category android:name="CATEG1" />
category = "CATEG1" <category android:name="CATEG2" />
</intent-filter>
category = ""
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
6
Intent Resolution: Data
URI = "content://contacts/1"
<intent-filter>
URI = "content://calls/20" <data android:scheme="content" />
</intent-filter>
URI = "tel:3344-5566"
7
Intent Resolution: Data
URI = ""
type = ""
<intent-filter>
</intent-filter>
URI = ""
type = "application/ogg"
<intent-filter>
URI = ""
<data android:type="application/ogg" />
type = ""
</intent-filter>
<intent-filter>
URI = "tel:3344-5566"
<data android:schema="tel" />
type = ""
</intent-filter>
<intent-filter>
URI = "" <data android:type="application/ogg"
type = "application/ogg" android:schema="content" />
</intent-filter>
<intent-filter>
URI = "content:/media/internal/audio/media/57" <data android:type=
type = "" "application/*" />
</intent-filter>
8
Mais Sobre Intent Resolution
Intent i = getIntent();
}
}
Actions Nativas
9
Actions Nativas: CALL
Uri uri = Uri.parse("tel:3344-5566");
Intent i = new Intent(Intent.ACTION_CALL, uri);
startActivity(i);
10
Categories Nativas
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
11
12