Começando com Android
Upcoming SlideShare
Loading in...5
×
 

Começando com Android

on

  • 796 views

Palestra apresentada por Ivan de Aguirre no AndroidDay 2013.

Palestra apresentada por Ivan de Aguirre no AndroidDay 2013.

Statistics

Views

Total Views
796
Views on SlideShare
725
Embed Views
71

Actions

Likes
0
Downloads
13
Comments
0

1 Embed 71

http://conf.sednasoft.com.br 71

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Começando com Android Começando com Android Presentation Transcript

  • Começando com Android Ivan de Aguirre @IvAguirre ivan.aguirre@dextra-sw.com
  • Agenda • Parte1: o • Fragmentação. o Aplicações Nativas ou Híbridas? o Interface o Android 4.3 Parte2: o Como o Android gerencia recursos o Threading o Memory leaks
  • Fragmentação
  • Fragmentação - níveis de API 4.0.3 - 4.0.4 API 15 Ice Cream Sandwich
  • Fragmentação - níveis de API 4.1 - API 16 4.2 - API 17 4.3 - API 18 Jelly Bean
  • Fragmentação - níveis de API android:minSDKVersion
  • Fragmentação - níveis de API http://developer.android.com/about/ dashboards/index.html#Platform
  • Fragmentação - níveis de API Google Play Developer Console
  • Fragmentação - níveis de API android:minSDKVersion=”10”
  • Fragmentação - níveis de API android:minSDKVersion=”10” Android Support Library
  • Fragmentação - tela OpenSignal http://opensignal.com/reports/ fragmentation-2013/
  • http://opensignal.com/reports/fragmentation-2013/
  • Fragmentação - tela - Screen Size small, normal, large, xlarge, sw600dp, w1024dp, h720dp, ...
  • Fragmentação - tela - Density dpi = dots per inch (ldpi, mdpi, hdpi, xhdpi) dp = density-independent pixel sp = scale-independent pixel wrap_content match_parent
  • <Button android:id="@+id/btn_ok" android:layout_width="match_parent" android:layout_height="100dp" android:text="@android:string/ok" />
  • Aplicações Nativas X Híbridas Android, iOS, Windows Phone...
  • Aplicações Nativas X Híbridas Android, iOS, Windows Phone... Custo-benefício de três aplicações > Custo de uma aplicação híbrida ?
  • Aplicações Nativas X Híbridas Aplicações Nativas X Aplicações Híbridas: código nativo + + JavaScript
  • Aplicações Nativas X Híbridas “You can write amazing Web 2.0 and Ajax apps that look exactly and behave exactly like apps on the iPhone. (...) And guess what? There’s no SDK that you need! You’ve got everything you need if you know how to write apps using the most modern web standards to write amazing apps for the iPhone today. So developers, we think we’ve got a very sweet story for you. You can begin building your iPhone apps today.” Steve Jobs, 2007
  • Aplicações Nativas X Híbridas “You can write amazing Web 2.0 and Ajax apps that look exactly and behave exactly like apps on the iPhone. (...) And guess what? There’s no SDK that you need! You’ve Só que não… got everything you need if you know how to write apps using the most modern web standards to write amazing apps for the iPhone today. So developers, we think we’ve got a very sweet story for you. You can begin building your iPhone apps today.” Steve Jobs, 2007
  • Aplicações Nativas X Híbridas Martin Fowler, Developing Software for Multiple Mobile Devices. http://martinfowler.com/articles/multiMobile/
  • Aplicações Nativas X Híbridas Martin Fowler, Developing Software for Multiple Mobile Devices. http://martinfowler.com/articles/multiMobile/ “but cross-platform failed for desktop, so why should we expect it to succeed for mobile?”
  • Aplicações Nativas X Híbridas Martin Fowler, Developing Software for Multiple Mobile Devices. http://martinfowler.com/articles/multiMobile/ “but cross-platform failed for desktop, so why should we expect it to succeed for mobile?” “To translate to all platforms, you can only use what all platforms support - which means you can only use a subset of each platform's behavior.”
  • Aplicações Nativas X Híbridas Martin Fowler, Developing Software for Multiple Mobile Devices. http://martinfowler.com/articles/multiMobile/ “but cross-platform failed for desktop, so why should we expect it to succeed for mobile?” “To translate to all platforms, you can only use what all platforms support - which means you can only use a subset of each platform's behavior.” “...UI translation leads you to... The Uncanny Valley”
  • Aplicações Nativas X Híbridas “Javascript is too slow for mobile app use in 2013 (e.g., for photo editing etc.). It’s slower than native code by about 5...“ http://sealedabstract.com/rants/whymobile-web-apps-are-slow/
  • Aplicações Nativas X Híbridas Se sua aplicação mobile for um diferencial para o seu negócio considere fazer nativa.
  • Aplicações Nativas X Híbridas Que tal site web otimizado para mobile, que execute no Browser?
  • Interfaces http://developer.android.com/design
  • Android 4.3 • Bluetooth Low Energy (Smart Ready). • Media DRM. • Interfaces Java para OpenGL ES 3.0. • Android key store. • Hardware credential storage.
  • Parte 2 Algumas boas práticas. Sim... vamos ver um pouco de código agora :)
  • Gerência de Recursos 0 100% A B C
  • Gerência de Recursos 0 100% B C
  • Gerência de Recursos 0 100% B C D
  • Gerência de Recursos 0 100% C D
  • Gerência de Recursos 0 100% C D A
  • Gerência de Recursos Activity: onSaveInstanceState(Bundle state) onRestoreInstanceState(Bundle state) onCreate(Bundle state)
  • Gerência de Recursos Fragment: onSaveInstanceState(Bundle state) setRetainInstance(boolean retain) onCreate(Bundle state) onCreateView(LayoutInflater inflater ,ViewGroup group, Bundle state) onActivityCreated(Bundle state)
  • Gerência de Recursos onCreate onStart onResume
  • Gerência de Recursos onCreate onStart onResume
  • Gerência de Recursos onCreate onStart onResume onSaveInstanceState onPause onStop onDestroy
  • Gerência de Recursos onCreate onStart onResume onSaveInstanceState onPause onStop onDestroy onCreate onStart onResume
  • Gerência de Recursos onCreate onStart onResume onSaveInstanceState onPause onStop State onDestroy onCreate onStart onResume
  • Thread de UI paint onClick paint paint onReceive onItemSelected paint onPause onStop paint onDestroy
  • Thread de UI paint onClick paint paint onReceive onItemSelected paint onPause onStop paint onDestroy ANR
  • Thread de UI paint onClick paint paint onReceive onItemSelected paint onPause onStop paint onDestroy
  • Thread de UI paint onClick paint paint onReceive onItemSelected paint onPause onStop paint onDestroy Worker Thread
  • Thread de UI paint onClick paint paint onReceive onItemSelected paint onPause onStop paint onDestroy Worker Thread
  • Threading AsyncTask
  • Threading public class Activity { public void onCreate(Bundle savedInstance) { ... DownloadTask task = new DownloadTask(); task.execute(); ... } }
  • Threading Loader
  • Threading AsyncQueryHandler IntentService Handler java.lang.Thread #sqn
  • Sincronização SyncAdapter GCM Polling
  • Memory Leaks http://www.curious-creature.org/ 2008/12/18/avoid-memory-leaks-onandroid/ Romain Guy, 2008
  • Memory Leak - Problema public class Util { private Context context; private static Util singleton; public static Util get(Context context) { if (singleton == null) { this.singleton = new Util(context); } return singleton; } public String getHello() { return context.getString(R.string.hello); } }
  • Memory Leak - Problema public class MyActivity extends Activity { public void onCreate(Bundle savedInstance) { ... Util util = Util.get(this); String hello = util.getHello(); ... }
  • Memory Leak - Solução 1 public static Util get(Context context) { if (singleton == null) { Context ctx = context .getApplicationContext(); this.singleton = new Util(ctx); } return singleton; }
  • Memory Leak - Solução 2 public class Util { public static String getHello(Context ctx) { return ctx.getString( R.string.hello); } }
  • Memory Leak - Solução 2 public class MyActivity { public void onCreate(Bundle savedInstance) { ... String hello = Util.getHello(this); ... } }
  • Perguntas?
  • Muito Obrigado! Ivan de Aguirre @IvAguirre ivan.aguirre@dextra-sw.com