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

Similar to 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 JavaScript
Ynon Perek
 

Similar to 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
 

Recently uploaded

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 

Recently uploaded (20)

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 

Conexao Java: Criando uma App Android