Monday, May 28, 12
Erich Egert                     Instrutor e desenvolvedor pela Caelum                                  encontre-me:       ...
ErissssshhhhhhMonday, May 28, 12
Monday, May 28, 12
Criando uma appMonday, May 28, 12
Por quê                     Android?Monday, May 28, 12
112.5         75      37.5           0                     2006     2007      2008        2009       2010         2011    ...
Monday, May 28, 12
Monday, May 28, 12
Razões do sucesso?Monday, May 28, 12
Monday, May 28, 12
Monday, May 28, 12
Monday, May 28, 12
+                         ADTMonday, May 28, 12
public class Onibus {                     	 private String nome;                     	 private String linha;              ...
public class Onibus {                      	 private String nome;                      	 private String linha;            ...
public class Onibus {                      	 private String nome;                      	 private String linha;            ...
Vários                     dispositivosMonday, May 28, 12
Único        Só pode                                 haver um!                     APK                                Vári...
Adapter                                   AsyncTask LayoutInflater             LocationManager                     MapActiv...
Monday, May 28, 12
Vamos começar                        devagar...Monday, May 28, 12
Emulador!!Monday, May 28, 12
Olá Mundo!Monday, May 28, 12
Hands on!Monday, May 28, 12
AndroidManifest.xml                     main.xml                                ?      OlaMundoActivity                   ...
Estrutura do                       ProjetoMonday, May 28, 12
res                     drawable                      layout                      valuesMonday, May 28, 12
res                     drawable                      layout                      valuesMonday, May 28, 12
res                     drawable                      layout                      valuesMonday, May 28, 12
res                     drawable                      <resources>                        ...                          <str...
Monday, May 28, 12
Tamanho?                     wrap_content   fill_parentMonday, May 28, 12
Manipulando                        a telaMonday, May 28, 12
Activity               comportamento      public class OnibusActivity extends Activity {      	    @Override      	    pub...
XML                     Activity                                  aparência               comportamento      public class ...
Activity                  XML                onCreate( )                     findViewById( )Monday, May 28, 12
Activity                  XML                onCreate( )                     findViewById( )Monday, May 28, 12
Hands on!Monday, May 28, 12
Listagem?Monday, May 28, 12
ListViewMonday, May 28, 12
Como?          List<PontoDeOnibus>Monday, May 28, 12
Adapter                 Objeto             ViewMonday, May 28, 12
List<PontoDeOnibus>                                              dados           new ArrayAdapter<PontoDeOnibus>(context, ...
layout                       linha.xmlMonday, May 28, 12
Hands on!Monday, May 28, 12
O visual é importante!Monday, May 28, 12
Hands on!Monday, May 28, 12
Tudo espalhado?Monday, May 28, 12
styles.xmlMonday, May 28, 12
Hands on!Monday, May 28, 12
E se...Monday, May 28, 12
Monday, May 28, 12
Tem como?!Monday, May 28, 12
SIM!!!Monday, May 28, 12
Application                     ResourcesMonday, May 28, 12
Hands on!Monday, May 28, 12
Monday, May 28, 12
Monday, May 28, 12
JSONMonday, May 28, 12
String json = //...Monday, May 28, 12
INTERNETMonday, May 28, 12
INTERNETMonday, May 28, 12
INTERNET                     AndroidManifest.xmlMonday, May 28, 12
INTERNET                     AndroidManifest.xmlMonday, May 28, 12
A reposta do                        server?Monday, May 28, 12
{                 JSON!!                                "linha": "1018-10",                                "nome": "Vila R...
JSON                              ????                     objeto                     ÔnibusMonday, May 28, 12
Quem poderá nos                         ajudar?Monday, May 28, 12
Mark Murphy - The Commons Guy                     Bibliotecas Marotas!Monday, May 28, 12
JSON                              public class Onibus {                              	 private String nome;               ...
JSON                                    GSON                              public class Onibus {                           ...
gson.jar                     libsMonday, May 28, 12
String json = //...Monday, May 28, 12
String json = //...     Gson gson =         new GsonBuilder().create();Monday, May 28, 12
String json = //...     Gson gson =         new GsonBuilder().create();     Onibus busao =       gson.fromJson(json,Onibus...
Hands on!Monday, May 28, 12
Próximo                     desafio?Monday, May 28, 12
Mapa?!?Monday, May 28, 12
Tem como?!?Monday, May 28, 12
MapActivityMonday, May 28, 12
ItemizedOverlay              PontoDeOnibus            OverlayItem                     Coordenada       GeoPointMonday, May...
Onde fazer a                       conversão?                     Coordenada   GeoPointMonday, May 28, 12
Utils?!Monday, May 28, 12
Ensinamentos do                     Aniche SkywalkerMonday, May 28, 12
public class Ponto {           	 //...           	 public OverlayItem toOverlayItem() {           	 	 return new OverlayIt...
Vamos testar??Monday, May 28, 12
Hands on!Monday, May 28, 12
instale!                                    confira o                                  código fonte!                     gi...
instale!                                                  confira o                                                código f...
OBRIGADO!                          @erichegt                     github.com/erichegtMonday, May 28, 12
Activity   ActivityMonday, May 28, 12
Activity   ActivityMonday, May 28, 12
INTENT!                     Activity     ActivityMonday, May 28, 12
Upcoming SlideShare
Loading in …5
×

Conexao Java: Criando uma App Android

6,709 views

Published on

Palestra do Conexão Java 2012 relativa a criação de uma App Mobile.

Published in: Technology

Conexao Java: Criando uma App Android

  1. 1. Monday, May 28, 12
  2. 2. Erich Egert Instrutor e desenvolvedor pela Caelum encontre-me: @erichegt github.com/erichegtMonday, May 28, 12
  3. 3. ErissssshhhhhhMonday, May 28, 12
  4. 4. Monday, May 28, 12
  5. 5. Criando uma appMonday, May 28, 12
  6. 6. Por quê Android?Monday, May 28, 12
  7. 7. 112.5 75 37.5 0 2006 2007 2008 2009 2010 2011 Palm/webOS Symbian Windows Mobile Windows Phone 7 RIM IOS AndroidMonday, May 28, 12
  8. 8. Monday, May 28, 12
  9. 9. Monday, May 28, 12
  10. 10. Razões do sucesso?Monday, May 28, 12
  11. 11. Monday, May 28, 12
  12. 12. Monday, May 28, 12
  13. 13. Monday, May 28, 12
  14. 14. + ADTMonday, May 28, 12
  15. 15. public class Onibus { private String nome; private String linha; //... }Monday, May 28, 12
  16. 16. public class Onibus { private String nome; private String linha; //... } Jar JVMMonday, May 28, 12
  17. 17. public class Onibus { private String nome; private String linha; //... } Jar APK JVM DalvikMonday, May 28, 12
  18. 18. Vários dispositivosMonday, May 28, 12
  19. 19. Único Só pode haver um! APK Vários dispositivosMonday, May 28, 12
  20. 20. Adapter AsyncTask LayoutInflater LocationManager MapActivity ExpandableListViewMonday, May 28, 12
  21. 21. Monday, May 28, 12
  22. 22. Vamos começar devagar...Monday, May 28, 12
  23. 23. Emulador!!Monday, May 28, 12
  24. 24. Olá Mundo!Monday, May 28, 12
  25. 25. Hands on!Monday, May 28, 12
  26. 26. AndroidManifest.xml main.xml ? OlaMundoActivity Entendendo...Monday, May 28, 12
  27. 27. Estrutura do ProjetoMonday, May 28, 12
  28. 28. res drawable layout valuesMonday, May 28, 12
  29. 29. res drawable layout valuesMonday, May 28, 12
  30. 30. res drawable layout valuesMonday, May 28, 12
  31. 31. res drawable <resources> ... <string name="cor">COR:</string> <string name="modelo">MODELO:</string> <string name="opcionais">OPCIONAIS:</string> layout <string name="salvar">SALVAR</string> </resources> valuesMonday, May 28, 12
  32. 32. Monday, May 28, 12
  33. 33. Tamanho? wrap_content fill_parentMonday, May 28, 12
  34. 34. Manipulando a telaMonday, May 28, 12
  35. 35. Activity comportamento public class OnibusActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //muitas coisas legais aqui! } }Monday, May 28, 12
  36. 36. XML Activity aparência comportamento public class OnibusActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //muitas coisas legais aqui! } }Monday, May 28, 12
  37. 37. Activity XML onCreate( ) findViewById( )Monday, May 28, 12
  38. 38. Activity XML onCreate( ) findViewById( )Monday, May 28, 12
  39. 39. Hands on!Monday, May 28, 12
  40. 40. Listagem?Monday, May 28, 12
  41. 41. ListViewMonday, May 28, 12
  42. 42. Como? List<PontoDeOnibus>Monday, May 28, 12
  43. 43. Adapter Objeto ViewMonday, May 28, 12
  44. 44. List<PontoDeOnibus> dados new ArrayAdapter<PontoDeOnibus>(context, layout, lista); Activity layoutMonday, May 28, 12
  45. 45. layout linha.xmlMonday, May 28, 12
  46. 46. Hands on!Monday, May 28, 12
  47. 47. O visual é importante!Monday, May 28, 12
  48. 48. Hands on!Monday, May 28, 12
  49. 49. Tudo espalhado?Monday, May 28, 12
  50. 50. styles.xmlMonday, May 28, 12
  51. 51. Hands on!Monday, May 28, 12
  52. 52. E se...Monday, May 28, 12
  53. 53. Monday, May 28, 12
  54. 54. Tem como?!Monday, May 28, 12
  55. 55. SIM!!!Monday, May 28, 12
  56. 56. Application ResourcesMonday, May 28, 12
  57. 57. Hands on!Monday, May 28, 12
  58. 58. Monday, May 28, 12
  59. 59. Monday, May 28, 12
  60. 60. JSONMonday, May 28, 12
  61. 61. String json = //...Monday, May 28, 12
  62. 62. INTERNETMonday, May 28, 12
  63. 63. INTERNETMonday, May 28, 12
  64. 64. INTERNET AndroidManifest.xmlMonday, May 28, 12
  65. 65. INTERNET AndroidManifest.xmlMonday, May 28, 12
  66. 66. A reposta do server?Monday, May 28, 12
  67. 67. { JSON!! "linha": "1018-10", "nome": "Vila Rosa - Metrô Santana", "pontos" : [ { "nome": "920016054", "descricao": "R. Dr. Neto De Araujo, 311", "coordenada": { "latitude": -23.5876, "longitude": -46.6321 } }, { "nome": "920016364", "descricao": "R.Vergueiro, 3039", "coordenada": { "latitude": -23.5875, "longitude": -46.6336 } } ] }Monday, May 28, 12
  68. 68. JSON ???? objeto ÔnibusMonday, May 28, 12
  69. 69. Quem poderá nos ajudar?Monday, May 28, 12
  70. 70. Mark Murphy - The Commons Guy Bibliotecas Marotas!Monday, May 28, 12
  71. 71. JSON public class Onibus { private String nome; private String linha; objeto private List<Ponto> pontos; Ônibus //... }Monday, May 28, 12
  72. 72. JSON GSON public class Onibus { private String nome; private String linha; objeto private List<Ponto> pontos; Ônibus //... }Monday, May 28, 12
  73. 73. gson.jar libsMonday, May 28, 12
  74. 74. String json = //...Monday, May 28, 12
  75. 75. String json = //... Gson gson = new GsonBuilder().create();Monday, May 28, 12
  76. 76. String json = //... Gson gson = new GsonBuilder().create(); Onibus busao = gson.fromJson(json,Onibus.class);Monday, May 28, 12
  77. 77. Hands on!Monday, May 28, 12
  78. 78. Próximo desafio?Monday, May 28, 12
  79. 79. Mapa?!?Monday, May 28, 12
  80. 80. Tem como?!?Monday, May 28, 12
  81. 81. MapActivityMonday, May 28, 12
  82. 82. ItemizedOverlay PontoDeOnibus OverlayItem Coordenada GeoPointMonday, May 28, 12
  83. 83. Onde fazer a conversão? Coordenada GeoPointMonday, May 28, 12
  84. 84. Utils?!Monday, May 28, 12
  85. 85. Ensinamentos do Aniche SkywalkerMonday, May 28, 12
  86. 86. public class Ponto { //... public OverlayItem toOverlayItem() { return new OverlayItem( this.localizacao.toGeoPoint(), "Localização:", this.descricao ); } } public class Coordenada { private static final double CONVERSION_SCALE = 1E6; //... public GeoPoint toGeoPoint() { Double geoLat = this.latitude * CONVERSION_SCALE; Double geoLng = this.longitude * CONVERSION_SCALE; return new GeoPoint(geoLat.intValue(), geoLng.intValue()); } }Monday, May 28, 12
  87. 87. Vamos testar??Monday, May 28, 12
  88. 88. Hands on!Monday, May 28, 12
  89. 89. instale! confira o código fonte! github/caelum/onibus-androidMonday, May 28, 12
  90. 90. instale! confira o código fonte! github/caelum/onibus-android Também na versão github/caelum/onibus-iosMonday, May 28, 12
  91. 91. OBRIGADO! @erichegt github.com/erichegtMonday, May 28, 12
  92. 92. Activity ActivityMonday, May 28, 12
  93. 93. Activity ActivityMonday, May 28, 12
  94. 94. INTENT! Activity ActivityMonday, May 28, 12

×