SlideShare uma empresa Scribd 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

Mais conteúdo relacionado

Semelhante 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
 

Semelhante 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

De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaRTTS
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»QADay
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 

Último (20)

De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

Conexao Java: Criando uma App Android