SlideShare a Scribd company logo
Monday, May 28, 12
Erich Egert
                     Instrutor e desenvolvedor pela Caelum


                                  encontre-me:
                                   @erichegt
                              github.com/erichegt



Monday, May 28, 12
Erissssshhhhhh



Monday, May 28, 12
Monday, May 28, 12
Criando uma app




Monday, May 28, 12
Por quê
                     Android?


Monday, May 28, 12
112.5




         75




      37.5




           0
                     2006     2007      2008        2009       2010         2011

                      Palm/webOS          Symbian          Windows Mobile
                      Windows Phone 7     RIM              IOS
                      Android

Monday, May 28, 12
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
+
                         ADT



Monday, May 28, 12
public class Onibus {
                     	 private String nome;
                     	 private String linha;
                       //...
                     }




Monday, May 28, 12
public class Onibus {
                      	 private String nome;
                      	 private String linha;
                        //...
                      }



                     Jar




                     JVM
Monday, May 28, 12
public class Onibus {
                      	 private String nome;
                      	 private String linha;
                        //...
                      }



                     Jar                  APK




                     JVM              Dalvik
Monday, May 28, 12
Vários
                     dispositivos
Monday, May 28, 12
Único        Só pode
                                 haver um!

                     APK




                                Vários
                             dispositivos
Monday, May 28, 12
Adapter
                                   AsyncTask




 LayoutInflater

             LocationManager

                     MapActivity                 ExpandableListView


Monday, May 28, 12
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




                      Entendendo...
Monday, May 28, 12
Estrutura do
                       Projeto

Monday, May 28, 12
res
                     drawable
                      layout
                      values
Monday, May 28, 12
res
                     drawable
                      layout
                      values
Monday, May 28, 12
res
                     drawable
                      layout
                      values
Monday, May 28, 12
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>




                      values
Monday, May 28, 12
Monday, May 28, 12
Tamanho?
                     wrap_content   fill_parent




Monday, May 28, 12
Manipulando
                        a tela

Monday, May 28, 12
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
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
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
ListView




Monday, May 28, 12
Como?
          List<PontoDeOnibus>




Monday, May 28, 12
Adapter

                 Objeto             View




Monday, May 28, 12
List<PontoDeOnibus>


                                              dados

           new ArrayAdapter<PontoDeOnibus>(context, layout, lista);



                      Activity

                     layout
Monday, May 28, 12
layout
                       linha.xml




Monday, 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.xml

Monday, 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
                     Resources

Monday, May 28, 12
Hands on!

Monday, May 28, 12
Monday, May 28, 12
Monday, May 28, 12
JSON




Monday, May 28, 12
String json = //...




Monday, May 28, 12
INTERNET




Monday, May 28, 12
INTERNET




Monday, May 28, 12
INTERNET


                     AndroidManifest.xml

Monday, May 28, 12
INTERNET


                     AndroidManifest.xml

Monday, May 28, 12
A reposta do
                        server?

Monday, May 28, 12
{


                 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
JSON
                              ????

                     objeto
                     Ônibus


Monday, 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;
                              	 private String linha;
                     objeto   	 private List<Ponto> pontos;

                     Ônibus       //...
                              }




Monday, May 28, 12
JSON
                                    GSON

                              public class Onibus {
                              	 private String nome;
                              	 private String linha;
                     objeto   	 private List<Ponto> pontos;

                     Ônibus       //...
                              }




Monday, May 28, 12
gson.jar


                     libs
Monday, 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.class);




Monday, May 28, 12
Hands on!


Monday, May 28, 12
Próximo
                     desafio?

Monday, May 28, 12
Mapa?!?




Monday, May 28, 12
Tem como?!?

Monday, May 28, 12
MapActivity

Monday, May 28, 12
ItemizedOverlay




              PontoDeOnibus            OverlayItem




                     Coordenada       GeoPoint

Monday, May 28, 12
Onde fazer a
                       conversão?

                     Coordenada   GeoPoint




Monday, May 28, 12
Utils?!



Monday, May 28, 12
Ensinamentos do
                     Aniche Skywalker




Monday, May 28, 12
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
Vamos testar??



Monday, May 28, 12
Hands on!

Monday, May 28, 12
instale!

                                    confira o
                                  código fonte!


                     github/caelum/onibus-android




Monday, May 28, 12
instale!

                                                  confira o
                                                código fonte!


                                 github/caelum/onibus-android

                                               Também na versão



                     github/caelum/onibus-ios

Monday, May 28, 12
OBRIGADO!



                          @erichegt
                     github.com/erichegt

Monday, May 28, 12
Activity   Activity


Monday, May 28, 12
Activity   Activity


Monday, May 28, 12
INTENT!

                     Activity     Activity


Monday, May 28, 12

More Related Content

PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
PDF
JavaScript por debaixo dos panos
PPTX
Como desenvolver e publicar aplicativos em Android no Google Play - Matheus P...
PDF
Oficina de aplicativos
PDF
Mobile conf erich
Storytelling For The Web: Integrate Storytelling in your Design Process
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
2024 Trend Updates: What Really Works In SEO & Content Marketing
JavaScript por debaixo dos panos
Como desenvolver e publicar aplicativos em Android no Google Play - Matheus P...
Oficina de aplicativos
Mobile conf erich

Recently uploaded (20)

PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Spectroscopy.pptx food analysis technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
A Presentation on Artificial Intelligence
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Tartificialntelligence_presentation.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Big Data Technologies - Introduction.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Spectroscopy.pptx food analysis technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
A Presentation on Artificial Intelligence
MYSQL Presentation for SQL database connectivity
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced methodologies resolving dimensionality complications for autism neur...
Empathic Computing: Creating Shared Understanding
Tartificialntelligence_presentation.pptx
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Big Data Technologies - Introduction.pptx
NewMind AI Weekly Chronicles - August'25-Week II
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
“AI and Expert System Decision Support & Business Intelligence Systems”
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Ad
Ad

Conexao Java: Criando uma App Android