SlideShare una empresa de Scribd logo
1 de 94
Descargar para leer sin conexión
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

Más contenido relacionado

Similar a Conexao Java: Criando uma App Android

Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningKevin McCarthy
 
The Future of Big Data is Relational (or why you can't escape SQL)
The Future of Big Data is Relational (or why you can't escape SQL)The Future of Big Data is Relational (or why you can't escape SQL)
The Future of Big Data is Relational (or why you can't escape SQL)OReillyStrata
 
Travis CI – what's inside?
Travis CI – what's inside?Travis CI – what's inside?
Travis CI – what's inside?Olga Lavrentieva
 
AppSec USA - LASCON Edition
AppSec USA - LASCON EditionAppSec USA - LASCON Edition
AppSec USA - LASCON EditionSherif Koussa
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScriptYnon Perek
 

Similar a Conexao Java: Criando uma App Android (6)

Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
The Future of Big Data is Relational (or why you can't escape SQL)
The Future of Big Data is Relational (or why you can't escape SQL)The Future of Big Data is Relational (or why you can't escape SQL)
The Future of Big Data is Relational (or why you can't escape SQL)
 
Travis CI – what's inside?
Travis CI – what's inside?Travis CI – what's inside?
Travis CI – what's inside?
 
AppSec USA - LASCON Edition
AppSec USA - LASCON EditionAppSec USA - LASCON Edition
AppSec USA - LASCON Edition
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScript
 
Spring Data JPA
Spring Data JPASpring Data JPA
Spring Data JPA
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Conexao Java: Criando uma App Android