Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[FLISOL] Android Faixa Branca (iniciando no And...

[FLISOL] Android Faixa Branca (iniciando no Android)

Palestra de introdução ao Android apresentada no FLISOL Campinas 2013.

Douglas Kayama

April 27, 2013

Transcript

92 slides
  1. eee19.com eu.about() • Bacharel em Ciência da Computação • Analista

    de software no Instituto de Pesquisas Eldorado • Sócio e co-fundador da Y-MAX Consultoria em TI
  2. eee19.com eu.about() • Bacharel em Ciência da Computação • Analista

    de software no Instituto de Pesquisas Eldorado • Sócio e co-fundador da Y-MAX Consultoria em TI • Organizador do GDG Campinas
  3. eee19.com Livre • the definition of open: "mkdir android ;

    cd android ; repo init -u git:// android.git.kernel.org/platform/manifest.git ; repo sync ; make" http://twitter.com/#!/arubin/status/27808662429
  4. eee19.com Broadcast Receiver • Não possui interface (com usuário)! •

    Roda em segundo plano! • Reage a mensagens de broadcast! • Exemplo: carga de bateria
  5. eee19.com Activity • Interface! • Um objetivo! • Várias por

    aplicativo! • Pode iniciar outras activities
  6. eee19.com Activity • 3 estados: ativa, em pausa e parada!

    • 3 ciclos de vida! • pode morrer a qualquer momento se não estiver ativa
  7. eee19.com Activity onCreate() onStart() onRestart() onResume() em execução onPause() onStop()

    onDestroy() shutdown Primeiro plano Visível Ciclo de vida completo
  8. eee19.com Prática • Criar uma aplicação com os métodos onCreate(),

    onStart(), onResume(), onPause(), onStop(), onDestroy() e onRestart()! • Colocar logs nesses métodos e observar o que acontece
  9. eee19.com View Group View View Group View View View View

    http://developer.android.com/guide/topics/ui/overview.html
  10. eee19.com Layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/ res/android" android:layout_width="match_parent" android:layout_height="match_parent"

    android:orientation="vertical" > <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, I am a TextView" /> <Button android:id="@+id/my_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, I am a Button" /> </LinearLayout> http://developer.android.com/
  11. eee19.com Eventos • Definir um listener e registrá-lo com a

    View! • Sobrecarregar um método de callback na View
  12. eee19.com Listeners • onClick() → View.OnClickListener! • onLongClick() → View.OnLongClickListener!

    • onFocusChange() → View.OnFocusChangeListener! • onKey() → View.OnKeyListener! • onTouch() → View.OnTouchListener! • onCreateContextMenu() → View.OnCreateContextMenuListener
  13. eee19.com Listeners // Create an anonymous implementation of OnClickListener private

    OnClickListener mCorkyListener = new OnClickListener() { public void onClick(View v) { // do something when the button is clicked } }; ! protected void onCreate(Bundle savedValues) { ... // Capture our button from layout Button button = (Button)findViewById(R.id.corky); // Register the onClick listener with the implementation above button.setOnClickListener(mCorkyListener); ... } http://developer.android.com/
  14. eee19.com Listeners public class ExampleActivity extends Activity implements OnClickListener {

    protected void onCreate(Bundle savedValues) { ... Button button = (Button)findViewById(R.id.corky); button.setOnClickListener(this); } ! // Implement the OnClickListener callback public void onClick(View v) { // do something when the button is clicked } ... } http://developer.android.com/
  15. eee19.com Intents • Comunicação intra e inter app de um

    jeito amigável e inteligente! • Serve para iniciar activities, services e broadcast receivers
  16. eee19.com Intents • Possui um alvo facultativo! • Se não

    tiver especificado alvo, o sistema encontra um! • Pode executar uma Activity ou Service específico! • IntentFilters
  17. eee19.com Intents Constante Alvo Ação ACTION_CALL activity Inicia uma ligação

    ACTION_EDIT activity Apresenta dados a serem editados ACTION_MAIN activity Activity inicial ACTION_SYNC activity Sincroniza dados com servidor ACTION_BATTERY_LOW broadcast receiver Aviso de bateria fraca ACTION_HEADSET_PLUG broadcast receiver Um fone de ouvido foi conectado ou desconectado ACTION_SCREEN_ON broadcast receiver A tela foi ligada (acesa) ACTION_TIMEZONE_CHANGED broadcast receiver Configurações de timezone modificadas
  18. eee19.com Intent filter <intent-filter . . . > <action android:name="com.example.project.SHOW_CURRENT"

    /> <action android:name="com.example.project.SHOW_RECENT" /> <action android:name="com.example.project.SHOW_PENDING" /> . . . </intent-filter> <intent-filter . . . > <data android:mimeType="video/mpeg" android:scheme="http" . . . /> <data android:mimeType="audio/mpeg" android:scheme="http" . . . /> . . . </intent-filter> http://developer.android.com/

More Decks by Douglas Kayama

Other Decks in Technology