Mini curso Android

665 views

Published on

Introdução ao desenvolvimento de aplicações móveis utilizando a plataforma Android.

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
665
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
38
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Mini curso Android

  1. 1. Android 100% Hands-on
  2. 2. GOOGLE ANdroid Mario Jorge Pereira
  3. 3. 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
  4. 4. Por onde começar? http://developer.android.com
  5. 5. ADT Bundle*: •Eclipse + ADT plugin •Android SDK Tools •Android Platform-tools *Pré requisito: JDK instalada
  6. 6. Desenvolvimento
  7. 7. Chega de Bla Bla Bla! Vamos Começar?
  8. 8. Eclipse + ADT
  9. 9. Olá MundoFile>New>AndroidApplicationProject
  10. 10. File>New>AndroidApplicationProject Olá Mundo
  11. 11. File>New>AndroidApplicationProject Olá Mundo
  12. 12. File>New>AndroidApplicationProject Olá Mundo
  13. 13. Olá Mundo
  14. 14. Para rodar precisamos do emulador Vamos criar?
  15. 15. AVD AndroidVirtual Device Maneger Android SDK Maneger
  16. 16. AVD AndroidVirtual Device Maneger
  17. 17. Inicie o emulador que voce criou? Isso demora :( … Depois que abrir não feche o Emulador!!
  18. 18. Run As.. Android application
  19. 19. Importante! Activity XML public class OlaMundo extends Activity { ! @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ola_mundo); } }
  20. 20. src/ 
 (código fonte: .java)" gen/
 (código gerado: R.java )" bin/
 (bytecodes: .dex)" libs/ 
 (bibliotecas)" res/ 
 (recursos: layouts, strigs, icones …)" assets/ 
 (outros recursos: arquivos em geral) Estrutura
  21. 21. <?xml version="1.0" encoding="utf-8"?> <resources> ! <string name="app_name">Alo Mundo</string> <string name="action_settings">Settings</string> <string name="hello_world">Hello world!</string> ! </resources> strings.xml
  22. 22. /* AUTO-GENERATED FILE. DO NOT MODIFY.*/ public final class R { public static final class attr { } public static final class dimen { public static final int activity_horizontal_margin=0x7f040000; public static final int activity_vertical_margin=0x7f040001; } public static final class layout { public static final int activity_main=0x7f030000; } ... } R.java
  23. 23. <?xml version="1.0" encoding=“utf-8"?> <manifest ...> ... <application ... > <activity android:name="br.com.mariojp.olamundo.OlaMundoActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> AndroidManifest.xml
  24. 24. Log.[nivel](“TAG”,“MENSAGEM”); ! Log.v (Verbose) Log.d (Debug) Log.i (Info) Log.w (Warning) Log.e (Erro) Log.wtf (...) Log
  25. 25. public class OlaMundoActivity extends Activity { ! @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.i("Ola mundo", "onCreate"); ! } ! } OlaMundoActivity.java
  26. 26. use o logging: Log.i(“Ciclo deVida”,”<método>”) nos métodos onCreate, onStart, onResume, onRestart, onPause, onStop e onDestroy. Entendendo o ciclo de vida
  27. 27. Run As.. Android application
  28. 28. Quais os métodos são chamados quando a aplicação inicia? O que Aconteceu Quando clicar em voltar qual método é executado? Alterando o aplicativo de Retrato para paisagem (control +F11) o que acontece?
  29. 29. Ainda no OlaMundo
  30. 30. O arquivo OlaMundoActivity.java public class OlaMundo extends Activity { ! @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ola_mundo); } ! }
  31. 31. Na pasta res/layout 1. Renomear o arquivo fragment_ola_mundo.xml para activity_ola_mundo.xml ! 2. Alterar a propriedade: tools:context=“br.com.mariojp.OlaMundoActivity”
  32. 32. Um pouco de Layout activity_ola_mundo.xml
  33. 33. <RelativeLayout ... > ... <Button android:id="@+id/botao" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Botao" /> ... </RelativeLayout> activity_ola_mundo.xml
  34. 34. Run As.. Android application
  35. 35. <LinearLayout xmlns:android="http://schemas.android.com/apk/ res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" tools:context="br.com.mariojp.olamundo.OlaMundoActivity" > ! . . . ! </LinearLayout> activity_ola_mundo.xml
  36. 36. Run As.. Android application
  37. 37. <LinearLayout xmlns:android="http://schemas.android.com/apk/ res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="br.com.mariojp.olamundo.OlaMundoActivity" > ! . . . ! </LinearLayout> activity_ola_mundo.xml
  38. 38. Run As.. Android application
  39. 39. <RelativeLayout ... > ... <Button android:id="@+id/botao" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Botao" /> ... </RelativeLayout> activity_ola_mundo.xml
  40. 40. Run As.. Android application
  41. 41. Um pouco de Comportamento OlaMundoActivity.java
  42. 42. [Tipo] var = ([Tipo]) findViewById(R.id.[id]); ! var.metodo(); ! findbyid
  43. 43. <RelativeLayout ... > ... <TextView android:id="@+id/texto" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> ... </RelativeLayout> activity_ola_mundo.xml
  44. 44. public class OlaMundoActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ola_mundo); TextView texto = (TextView) findViewById(R.id.texto); texto.setText("Outro Texto"); } ! } OlaMundoActivity.java
  45. 45. Run As.. Android application
  46. 46. Botão Aplicação Listener Clicou? Ação do Botão
  47. 47. public class OlaMundoActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ola_mundo); ! Button button = (Button) findViewById(R.id.botao); button.setOnClickListener(new Ouvinte()); } } OlaMundoActivity.java
  48. 48. public class Ouvinte implements OnClickListener { ! @Override public void onClick(View clicado) { Log.i("TAG", "Botao Clicado"); } ! } Ouvinte.java
  49. 49. Run As.. Android application
  50. 50. public class OlaMundoActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ola_mundo); Button button = (Button) findViewById(R.id.botao); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.i("TAG", "Botao Clicado"); } }); } } OlaMundoActivity.java
  51. 51. Run As.. Android application
  52. 52. <RelativeLayout ... > ... <Button android:id="@+id/botao" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Botao" android:onClick="metodo" /> ... </RelativeLayout> activity_ola_mundo.xml
  53. 53. public class OlaMundoActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ola_mundo); } public void metodo(View v) { Log.i("TAG", "Botao Clicado"); } OlaMundoActivity.java
  54. 54. Run As.. Android application
  55. 55. Toast.makeText(this, "TEXTO", Toast.LENGTH_LONG).show(); ! ! Toast.LENGTH_LONG ! Toast.LENGTH_SHORT ! TOAST
  56. 56. public class OlaMundoActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ola_mundo); } public void metodo(View v) { Toast.makeText(this, "AloMundo!", Toast.LENGTH_LONG).show(); } ! } OlaMundoActivity.java
  57. 57. Run As.. Android application
  58. 58. Faculdade File > New > Android Application Project
  59. 59. Crie o projeto Android File > New > Android Application Project
  60. 60. public class ListaDisciplinas extends Activity { ! @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.lista_diciplinas); } } ListaDisciplinas.java
  61. 61. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > ! <ListView android:id="@+id/lista_disciplinas" android:layout_width="match_parent" android:layout_height="match_parent" > </ListView> ! </LinearLayout> lista_disciplinas.xml
  62. 62. public class ListaDisciplinas extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.lista_diciplinas); ! String[] disciplinas = {"Redes", "Algoritimos", "Programacao"}; int layout = android.R.layout.simple_list_item_1; ! ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,layout, disciplinas); ! ListView lista = (ListView) findViewById(R.id.lista_disciplinas); ! lista.setAdapter(adapter); ! } } ListaDisciplinas.java
  63. 63. Run As.. Android application
  64. 64. public class ListaDisciplinas extends Activity { ! @Override protected void onCreate(Bundle savedInstanceState) { ... ! lista.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapter, View view, int posicao, long id) { Toast.makeText(ListaDisciplinas.this, "Clicou "+posicao, Toast.LENGTH_SHORT).show(); } }); } } ListaDisciplinas.java
  65. 65. Run As.. Android application
  66. 66. public class ListaDisciplinas extends Activity { ! @Override protected void onCreate(Bundle savedInstanceState) { ... lista.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> adapter, View view, int posicao, long id) { Toast.makeText( ListaDisciplinas.this, adapter.getItemAtPosition(posicao).toString(), Toast.LENGTH_SHORT).show(); return false; } }); } } ListaDisciplinas.java
  67. 67. Run As.. Android application
  68. 68. O que aconteceu ate aqui? Repare que o onItemLongClick retorna false => troque por true.
  69. 69. Run As.. Android application
  70. 70. Vamos criar um formulário
  71. 71. File>New>AndroidXMLFile res/layout/disciplina.xml
  72. 72. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Disciplina" /> <EditText android:id="@+id/disciplina" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > <requestFocus /> </EditText> . . . </LinearLayout> disciplinas.xml
  73. 73. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > ! . . . ! <EditText android:id="@+id/nota2" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="numberSigned" /> <Button android:id="@+id/botao" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Salvar" /> ! </LinearLayout> disciplinas.xml
  74. 74. Pode usar o Editor
  75. 75. android.app.Activity File>New>Class
  76. 76. public class DisciplinaActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.disciplina); } ! } DisciplinaActivity.java
  77. 77. public class ListaDisciplinas extends Activity { . . . public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.lista_disciplinas, menu); return super.onCreateOptionsMenu(menu); } } ListaDisciplinas.java
  78. 78. <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context="br.com.mariojp.faculdade.ListaDisciplinas" > ! <item android:id="@+id/novo" android:showAsAction="always" android:icon="@android:drawable/btn_plus" android:title="Novo"/> ! </menu> lista_disciplinas.xml
  79. 79. public class ListaDisciplinas extends Activity { . . . public boolean onOptionsItemSelected(MenuItem item) { int itemClicado = item.getItemId(); switch (itemClicado) { case R.id.novo: Intent intent = new Intent(this, Disciplina.class); startActivity(intent); break; default: break; } return super.onOptionsItemSelected(item); } } ListaDisciplinas.java
  80. 80. Run As.. Android application
  81. 81. <?xml version="1.0" encoding=“utf-8"?> <manifest ...> . . . <application ... > <activity android:name="br.com.mariojp.faculdade.Disciplina"> </activity> . . . </application> </manifest> AndroidManifest.xml
  82. 82. Run As.. Android application
  83. 83. public class DisciplinaActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.disciplina); Button button = (Button) findViewById(R.id.botao); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); } DisciplinaActivity.java
  84. 84. Run As.. Android application
  85. 85. Banco de dados
  86. 86. Vamos pensar um pouco… DisciplinaDAO SQLiteOpenHelper ListaDisciplinas
  87. 87. public class Disciplina { private Long id; private String disciplina; private String professor; private String email; private Double nota1; private Double nota2; // Gerar Get’s e Set's } Disciplina.java
  88. 88. public class DisciplinaDAO extends SQLiteOpenHelper { ! private static final String DATABASE = "BancoDisciplinas"; private static final int VERSAO = 1; ! public DisciplinaDAO(Context context) { super(context, DATABASE, null, VERSAO); } ! //... ! } DisciplinaDAO.java
  89. 89. public class DisciplinaDAO extends SQLiteOpenHelper { ! private static final String DATABASE = "BancoDisciplinas"; private static final int VERSAO = 1; ! public DisciplinaDAO(Context context) { super(context, DATABASE, null, VERSAO); } ! public void onCreate(SQLiteDatabase db) { String ddl ="CREATE TABLE Disciplinas (id INTEGER PRIMARY KEY," + " disciplina TEXT UNIQUE NOT NULL," + " professor TEXT," + " email TEXT," + " nota1 REAL, nota2 REAL);"; db.execSQL(ddl); } ! //... ! } DisciplinaDAO.java
  90. 90. public class DisciplinaDAO extends SQLiteOpenHelper { ! private static final String DATABASE = "BancoDisciplinas"; private static final int VERSAO = 1; ! public DisciplinaDAO(Context context) { super(context, DATABASE, null, VERSAO); } //... ! @Override public void onUpgrade(SQLiteDatabase db, int velha, int nova) { String ddl ="DROP TABLE IF EXISTS Disciplinas"; db.execSQL(ddl); onCreate(db); } ! //... } DisciplinaDAO.java
  91. 91. public class DisciplinaDAO extends SQLiteOpenHelper { ! //... ! public void salvar(Disciplina disciplina) { ContentValues values = new ContentValues(); values.put("disciplina", disciplina.getDisciplina()); values.put("professor", disciplina.getProfessor()); values.put("email", disciplina.getEmail()); values.put("nota1", disciplina.getNota1()); values.put("nota2", disciplina.getNota2()); getWritableDatabase().insert("Disciplinas", null, values ); } ! //... } DisciplinaDAO.java
  92. 92. public class DisciplinaActivity extends Activity { private EditText nomeDisciplina; // ...nomeProfessor, email, nota1, nota2; ! protected void onCreate(Bundle savedInstanceState) { nomeDisciplina = (EditText) findViewById(R.id.disciplina); //... outros findViewById ! Button button = (Button) findViewById(R.id.botao); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { Disciplina disciplina = new Disciplina(); disciplina.setDisciplina(nomeDisciplina.getText().toString()); // outros set's DisciplinaDAO dao = new DisciplinaDAO(DisciplinaActivity.this); dao.salvar(disciplina); dao.close(); finish(); } }); } } DisciplinaActivity.java
  93. 93. public class ListaDisciplinas extends Activity { ! private ListView lista; ! protected void onCreate(Bundle savedInstanceState) { //... lista = (ListView) findViewById(R.id.lista_disciplinas); ! DisciplinaDAO dao = new DisciplinaDAO(this); ArrayList<Disciplina> disciplinas= dao.getLista(); dao.close(); ! ArrayAdapter<Disciplina> adapter = new ArrayAdapter<Disciplina>( this, android.R.layout.simple_list_item_1, disciplinas); lista.setAdapter(adapter); //... } //... } ListaDisciplinas.java
  94. 94. Run As.. Android application
  95. 95. public class ListaDisciplinas extends Activity { //... protected void onResume() { super.onResume(); DisciplinaDAO dao = new DisciplinaDAO(this); ArrayList<Disciplina> disciplinas= dao.getLista(); dao.close(); ! ArrayAdapter<Disciplina> adapter = new ArrayAdapter<Disciplina>( this, layout,android.R.layout.simple_list_item_1); lista.setAdapter(adapter); } //... } ListaDisciplinas.java
  96. 96. Run As.. Android application
  97. 97. public class ListaDisciplinas extends Activity { //... @Override protected void onResume() { super.onResume(); carregarLista(); } ! private void carregarLista() { DisciplinaDAO dao = new DisciplinaDAO(this); ArrayList<Disciplina> disciplinas= dao.getLista(); dao.close(); int layout = android.R.layout.simple_list_item_1; ArrayAdapter<Disciplina> adapter = new ArrayAdapter<Disciplina>(this, layout, disciplinas); lista.setAdapter(adapter); } //... } ListaDisciplinas.java
  98. 98. public class DisciplinaDAO extends SQLiteOpenHelper { //... ! public void deletar(Disciplina disciplina) { String[] args = { disciplina.getId().toString() }; getWritableDatabase().delete("Disciplinas", "id=?", args); } ! //... } DisciplinaDAO.java
  99. 99. public class ListaDisciplinas extends Activity { ! private ListView lista; ! protected void onCreate(Bundle savedInstanceState) { //... lista = (ListView) findViewById(R.id.lista_disciplinas); registerForContextMenu(lista); //... } //... } ListaDisciplinas.java
  100. 100. public class ListaDisciplinas extends Activity { //... @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add("Enviar E-mail"); MenuItem deletar = menu.add("Deletar"); deletar.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { DisciplinaDAO dao = new DisciplinaDAO(ListaDisciplinas.this); dao.deletar(disciplina); dao.close(); carregarLista(); return false; } }); } //... } ListaDisciplinas.java
  101. 101. public class ListaDisciplinas extends Activity { ! private ListView lista; private Disciplina disciplina; protected void onCreate(Bundle savedInstanceState) // ... lista.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> adapter, View view,int posicao, long id) { disciplina = (Disciplina) adapter.getItemAtPosition(posicao); return false; } }); // ... } // ... } ListaDisciplinas.java
  102. 102. Run As.. Android application
  103. 103. lista.setOnItemClickListener(new OnItemClickListener() { ! public void onItemClick(AdapterView<?> adapter, View view, int posicao, long id) { ! Disciplina disciplina = (Disciplina) adapter.getItemAtPosition(posicao); ! Intent intent = new Intent(ListaDisciplinas.this,DisciplinaActivity.class); ! intent.putExtra("disciplinaSelecionada", disciplina); ! startActivity(intent); ! } }); ListaDisciplinas.java
  104. 104. public class DisciplinaActivity extends Activity { private EditText nomeDisciplina; // ...nomeProfessor, email, nota1, nota2; protected void onCreate(Bundle savedInstanceState) { Button button = (Button) findViewById(R.id.botao); Intent intent = getIntent(); disciplinaSelecionada = (Disciplina) intent.getSerializableExtra("disciplinaSelecionada"); if(disciplinaSelecionada!=null){ button.setText("Alterar"); nomeDisciplina.setText(disciplinaSelecionada.getDisciplina()); } button.setOnClickListener(new OnClickListener() { public void onClick(View v) { Disciplina disciplina = new Disciplina(); disciplina.setDisciplina(nomeDisciplina.getText().toString()); /. . . DisciplinaDAO dao = new DisciplinaDAO(DisciplinaActivity.this); if(disciplinaSelecionada == null){ dao.salvar(disciplina); }else{ disciplina.setId(disciplinaSelecionada.getId()); dao.alterar(disciplina); } dao.close(); finish(); } }); } } DisciplinaActivity.java
  105. 105. public class DisciplinaDAO extends SQLiteOpenHelper { //... public void alterar(Disciplina disciplina) { ContentValues values = new ContentValues(); values.put("disciplina", disciplina.getDisciplina()); values.put("professor", disciplina.getProfessor()); values.put("email", disciplina.getEmail()); values.put("nota1", disciplina.getNota1()); values.put("nota2", disciplina.getNota2()); getWritableDatabase().update("Disciplinas", values, "id=?", new String[]{disciplina.getId().toString()}); } //... } DisciplinaDAO.java
  106. 106. Run As.. Android application
  107. 107. public class ListaDisciplinas extends Activity { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); //. . . MenuItem email = menu.add("Enviar E-mail"); Intent intentEmail = new Intent(Intent.ACTION_SEND); intentEmail.setType("message/rfc822"); intentEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "mariojp@gmail.com" }); intentEmail.putExtra(Intent.EXTRA_SUBJECT, "ANDROID"); intentEmail.putExtra(Intent.EXTRA_TEXT, "LEGAL!!!"); email.setIntent(intentEmail); //. . . } } ListaDisciplinas.java
  108. 108. Run As.. Android application
  109. 109. public class DisciplinaActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { foto = (ImageView) findViewById(R.id.foto); foto.setOnClickListener(new OnClickListener() { ! @Override public void onClick(View v) { Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); caminho = Environment.getExternalStorageDirectory().toString() +"/"+System.currentTimeMillis()+".png"; File arquivo = new File(caminho); Uri localImage = Uri.fromFile(arquivo); camera.putExtra(MediaStore.EXTRA_OUTPUT, localImage); startActivityForResult(camera, 999); } }); } } DisciplinaActivity.java
  110. 110. public class DisciplinaActivity extends Activity { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode == 999){ if(resultCode == Activity.RESULT_OK){ Bitmap bitmap = BitmapFactory.decodeFile(caminho); Bitmap bitmapReduzido =Bitmap.createScaledBitmap(bitmap, 100, 100, true); foto.setImageBitmap(bitmapReduzido); }else{ caminho =null; } } } } DisciplinaActivity.java
  111. 111. <?xml version="1.0" encoding=“utf-8"?> <manifest ...> … <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> … </manifest> AndroidManifest.xml
  112. 112. Run As.. Android application
  113. 113. Esta obra está licenciada sob a licença Creative Commons Atribuição-CompartilhaIgual 3.0 Não Adaptada. Para ver uma cópia desta licença, visite http://creativecommons.org/licenses/by-sa/3.0/.
  114. 114. ANDROID Mario Jorge Pereira Como me encontrar? http://www.mariojp.com.br twitter.com/@mariojp mariojp@gmail.com

×