PROGRAMAÇÃO PARA
DISPOSITIVOS MÓVEIS
Aula 3 – Intents (parte 2)
Objetivos da aula
 Estatística das APIs
 Relembrar as Intents
 O que faltou das Intents
 Views
Estatísticas das APIs
Data collected during a 7-day period ending on April 1, 2014.
Any versions with less than 0.1% distribution are not shown.
Fonte: http://developer.android.com/about/dashboards/index.html
Objetivos da aula
 Estatística das APIs
 Relembrar as Intents
 O que faltou das Intents
 Views
Iniciando outra Activity
1. public void onClick(View v) {
2. Intent minhaIntencao = new Intent(this, Activity2.class);
3. startActivity(minhaIntencao);
4. }
Vamos praticar!
Objetivos da aula
 Estatística das APIs
 Relembrar as Intents
 O que faltou das Intents
 Views
Como enviar dados?
1. public void onClick(View v) {
2. Intent minhaIntencao = new Intent(this, Activity2.class);
3. startActivity(minhaIntencao);
4. }
Como enviar dados?
1. public void onClick(View v) {
2. Intent minhaIntencao = new Intent(this, Activity2.class);
3. minhaIntencao.putExtra("mensagem", "Ola");
4. startActivity(minhaIntencao);
5. }
Como enviar dados? Ou...
1. public void onClick(View v) {
2. Intent minhaIntencao = new Intent(this, Activity2.class);
3. Bundle bundle = new Bundle();
4. bundle.putString("mensagem", "teste bundle");
5. it.putExtras(bundle);
6. startActivity(minhaIntencao);
7. }
Como enviar dados? Ou...
1. public void onClick(View v) {
2. Intent minhaIntencao = new Intent(this, Activity2.class);
3. Bundle bundle = new Bundle();
4. bundle.putString("mensagem", "teste bundle");
5. it.putExtras(bundle);
6. startActivity(minhaIntencao);
7. }
Como enviar dados? Ou...
1. public void onClick(View v) {
2. Intent minhaIntencao = new Intent(this, Activity2.class);
3. Bundle bundle = new Bundle();
4. bundle.putString("mensagem", "teste bundle");
5. it.putExtras(bundle);
6. startActivity(minhaIntencao);
7. }
Como receber os dados?
1. public void onCreate(Bundle savedInstanceState) {
2. ...
3. Bundle params = getIntent().getExtras();
4.
5. if (params != null) {
6. String mostraTexto = params.getString("mensagem");
7. textView.setText(mostraTexto);
8. setContentView(textView);
9. }
10.}
Como receber os dados?
1. public void onCreate(Bundle savedInstanceState) {
2. ...
3. Bundle params = getIntent().getExtras();
4.
5. if (params != null) {
6. String mostraTexto = params.getString("mensagem");
7. textView.setText(mostraTexto);
8. setContentView(textView);
9. }
10.}
Como receber os dados?
1. public void onCreate(Bundle savedInstanceState) {
2. ...
3. Bundle params = getIntent().getExtras();
4.
5. if (params != null) {
6. String mostraTexto = params.getString("mensagem");
7. textView.setText(mostraTexto);
8. setContentView(textView);
9. }
10.}
Como receber os dados?
1. public void onCreate(Bundle savedInstanceState) {
2. ...
3. Bundle params = getIntent().getExtras();
4.
5. if (params != null) {
6. String mostraTexto = params.getString("mensagem");
7. textView.setText(mostraTexto);
8. setContentView(textView);
9. }
10.}
Vamos praticar!
Obrigado!

Aula 10 04 (intents)

  • 1.
  • 2.
    Objetivos da aula Estatística das APIs  Relembrar as Intents  O que faltou das Intents  Views
  • 3.
    Estatísticas das APIs Datacollected during a 7-day period ending on April 1, 2014. Any versions with less than 0.1% distribution are not shown. Fonte: http://developer.android.com/about/dashboards/index.html
  • 4.
    Objetivos da aula Estatística das APIs  Relembrar as Intents  O que faltou das Intents  Views
  • 5.
    Iniciando outra Activity 1.public void onClick(View v) { 2. Intent minhaIntencao = new Intent(this, Activity2.class); 3. startActivity(minhaIntencao); 4. }
  • 6.
  • 7.
    Objetivos da aula Estatística das APIs  Relembrar as Intents  O que faltou das Intents  Views
  • 8.
    Como enviar dados? 1.public void onClick(View v) { 2. Intent minhaIntencao = new Intent(this, Activity2.class); 3. startActivity(minhaIntencao); 4. }
  • 9.
    Como enviar dados? 1.public void onClick(View v) { 2. Intent minhaIntencao = new Intent(this, Activity2.class); 3. minhaIntencao.putExtra("mensagem", "Ola"); 4. startActivity(minhaIntencao); 5. }
  • 10.
    Como enviar dados?Ou... 1. public void onClick(View v) { 2. Intent minhaIntencao = new Intent(this, Activity2.class); 3. Bundle bundle = new Bundle(); 4. bundle.putString("mensagem", "teste bundle"); 5. it.putExtras(bundle); 6. startActivity(minhaIntencao); 7. }
  • 11.
    Como enviar dados?Ou... 1. public void onClick(View v) { 2. Intent minhaIntencao = new Intent(this, Activity2.class); 3. Bundle bundle = new Bundle(); 4. bundle.putString("mensagem", "teste bundle"); 5. it.putExtras(bundle); 6. startActivity(minhaIntencao); 7. }
  • 12.
    Como enviar dados?Ou... 1. public void onClick(View v) { 2. Intent minhaIntencao = new Intent(this, Activity2.class); 3. Bundle bundle = new Bundle(); 4. bundle.putString("mensagem", "teste bundle"); 5. it.putExtras(bundle); 6. startActivity(minhaIntencao); 7. }
  • 13.
    Como receber osdados? 1. public void onCreate(Bundle savedInstanceState) { 2. ... 3. Bundle params = getIntent().getExtras(); 4. 5. if (params != null) { 6. String mostraTexto = params.getString("mensagem"); 7. textView.setText(mostraTexto); 8. setContentView(textView); 9. } 10.}
  • 14.
    Como receber osdados? 1. public void onCreate(Bundle savedInstanceState) { 2. ... 3. Bundle params = getIntent().getExtras(); 4. 5. if (params != null) { 6. String mostraTexto = params.getString("mensagem"); 7. textView.setText(mostraTexto); 8. setContentView(textView); 9. } 10.}
  • 15.
    Como receber osdados? 1. public void onCreate(Bundle savedInstanceState) { 2. ... 3. Bundle params = getIntent().getExtras(); 4. 5. if (params != null) { 6. String mostraTexto = params.getString("mensagem"); 7. textView.setText(mostraTexto); 8. setContentView(textView); 9. } 10.}
  • 16.
    Como receber osdados? 1. public void onCreate(Bundle savedInstanceState) { 2. ... 3. Bundle params = getIntent().getExtras(); 4. 5. if (params != null) { 6. String mostraTexto = params.getString("mensagem"); 7. textView.setText(mostraTexto); 8. setContentView(textView); 9. } 10.}
  • 17.
  • 19.