SlideShare uma empresa Scribd logo
1 de 31
Android application
development basics
     Anton Narusberg
Hello, I’m Anton.

• Developer since 2006
• Android developer since 2010
• Partner at Cannedapps
Topics

• Getting up and running with Android SDK
• "Hello World!"
• Deeper dive into Android application
  components
Android SDK
• Speed, Power, Control
• Standardized user experience
• Ability to be on the edge
• Integration
Getting started

• Java Development Kit (JDK)
• IDE (Eclipse recommended)
• Android SDK
• Android Development Tools (ADT)
ADT plugin for Eclipse
• SDK Tools Integration
• Code Editors
• Layout Refactoring Support
• Android Virtual Devices Manager
• DDMS
• ...
more at http://developer.android.com/guide/developing/tools/adt.html
“Hello eSport!”
Android application
         components

• Activity
• Layouts & Views
• Service
• Intent
• AndroidManifest.xml
Activity
Activity
UI concept that represents a single screen on your app
Activity
UI concept that represents a single screen on your app




DashboardActivity                TrainingActivity
Activity lifecycle
DashboardActivity
public class DashboardActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.dashboard);

        preferences = PreferenceManager.getDefaultSharedPreferences(this);

        initViews();
        initShadows();
        attachEvents();
    }

    @Override
    protected void onResume() {
      shadower.turnOn();
      super.onResume();
    }

    @Override
    protected void onPause() {
      shadower.turnOff();
      super.onPause();
    }

    ....

}
Dashboard layout
Dashboard layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/background_gradient">

  <ImageView
    android:layout_width="40dp"
    android:layout_height="36dp"
    android:layout_marginTop="18dp"
    android:layout_marginLeft="15dp"
    android:background="@drawable/logo_run"/>



  <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="170dp"
    android:layout_alignParentBottom="true">

    <ImageView
      android:id="@+id/dashboard_history_button_shadow"
      android:layout_width="100dp"
      android:layout_height="97dp"
      android:layout_marginLeft="110dp"
      android:background="@drawable/menu_history_shadow"/>

    <Button
      android:id="@+id/dashboard_history_button"
      android:layout_width="100dp"
      android:layout_height="97dp"
      android:layout_marginLeft="110dp"
      android:background="@drawable/menu_history"/>

    .......

  </RelativeLayout>

</RelativeLayout>
Service
Background process that can run for a long time
Service
Background process that can run for a long time
Binding the Service from Activity
public class TrainingActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate();
      Intent intent = new Intent(this, RunningSessionService.class);
      bindService(intent, sessionConnection, BIND_AUTO_CREATE);
    }

    @Override
    protected void onDestroy() {
      unbindService(sessionConnection);
      super.onDestroy();
    }

    private ServiceConnection sessionConnection = new ServiceConnection() {

         public void onServiceDisconnected(ComponentName name) {}

         public void onServiceConnected(ComponentName name, IBinder serviceBinding) {
           RunningSessionService.SessionBinder binding = (RunningSessionService.SessionBinder) serviceBinding;
           session = binding.getService();
         }
    };

    public void onStartTrackingClicked() {
      if (session != null) {
        session.startTracking();
      }
    }

}
Binding the Service from Activity
public class RunningSessionService extends Service {

    @Override
    public void onCreate() {
      super.onCreate();
      init();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {}

    @Override
    public void onDestroy() {}

    @Override
    public IBinder onBind(Intent intent) {
      binding = new SessionBinder(this);
      return binding;
    }

    @Override
    public boolean onUnbind(Intent intent) {
      stopSelf();
      return super.onUnbind(intent);
    }

    public void startTracking() {
      ...
    }

    public void stopTracking() {
      ...
    }
}
Intent


•   An "intention" to do some work:

    •   Broadcast a message

    •   Start a Service

    •   Launch an Activity

    •   Display a web page or a list of contacts

    •   dial a phone nr. or answer a call

    •   etc.
Launching next Activity with an Intent




DashboardActivity         TrainingActivity
Intent
public class DashboardActivity extends Activity {

    private void initViews() {
      runButton = (Button) findViewById(R.id.dashboard_run_button);
      historyButton = (Button) findViewById(R.id.dashboard_history_button);
    }

    private void attachEvents() {
      runButton.setOnClickListener(new View.OnClickListener() {

          public void onClick(View v) {
            Intent intent = new Intent(DashboardActivity.this, SelectTrackActivity.class);
            startActivity(intent);
          }
        });

        ...

    }

    ...

}
AndroidManifest.xml
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.cannedapps.runner"
  android:versionCode="1"
  android:versionName="1.0">

  <uses-sdk android:minSdkVersion="3"/>

  <application
    android:name="Runner"
    android:label="@string/app_name"
    android:icon="@drawable/ic_launcher_run"
    android:theme="@android:style/Theme.NoTitleBar">

    <activity
      android:name="DashboardActivity"
      android:label="@string/app_name"
      android:screenOrientation="portrait">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name=".SettingsActivity"/>
    <activity
      android:name="TracksActivity"
      android:screenOrientation="portrait"/>
      ...

    <service android:enabled="true" android:name=".tracking.RunningSessionService"/>
  </application>

  <uses-permission   android:name="android.permission.INTERNET"/>
  <uses-permission   android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission   android:name="android.permission.ACCESS_FINE_LOCATION"/>
  <uses-permission   android:name="android.permission.WAKE_LOCK"/>

</manifest>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.cannedapps.runner"
  android:versionCode="1"
  android:versionName="1.0">

  <uses-sdk android:minSdkVersion="3"/>

  <application
    android:name="Runner"
    android:label="@string/app_name"                                                   Describe Activities & Services
    android:icon="@drawable/ic_launcher_run"
    android:theme="@android:style/Theme.NoTitleBar">

    <activity
      android:name="DashboardActivity"
      android:label="@string/app_name"
      android:screenOrientation="portrait">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name=".SettingsActivity"/>
    <activity
      android:name="TracksActivity"
      android:screenOrientation="portrait"/>
      ...

    <service android:enabled="true" android:name=".tracking.RunningSessionService"/>
  </application>
                                                                                           Describe Permissions
  <uses-permission   android:name="android.permission.INTERNET"/>
  <uses-permission   android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission   android:name="android.permission.ACCESS_FINE_LOCATION"/>
  <uses-permission   android:name="android.permission.WAKE_LOCK"/>

</manifest>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"                        General setup
  package="com.cannedapps.runner"
  android:versionCode="1"
  android:versionName="1.0">

  <uses-sdk android:minSdkVersion="3"/>

  <application
    android:name="Runner"
    android:label="@string/app_name"                                                   Describe Activities & Services
    android:icon="@drawable/ic_launcher_run"
    android:theme="@android:style/Theme.NoTitleBar">

    <activity
      android:name="DashboardActivity"
      android:label="@string/app_name"
      android:screenOrientation="portrait">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name=".SettingsActivity"/>
    <activity
      android:name="TracksActivity"
      android:screenOrientation="portrait"/>
      ...

    <service android:enabled="true" android:name=".tracking.RunningSessionService"/>
  </application>
                                                                                           Describe Permissions
  <uses-permission   android:name="android.permission.INTERNET"/>
  <uses-permission   android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission   android:name="android.permission.ACCESS_FINE_LOCATION"/>
  <uses-permission   android:name="android.permission.WAKE_LOCK"/>

</manifest>
Publishing to the Market

1. Sign up at https://market.android.com/publish
     - 25$ fee

2. Prepare your application Package
    - Test it
    - Build it
    - Sign it

3. Upload promotional material

4. Publish
Questions?

   Anton Narusberg
anton@cannedapps.com
   @antonnarusberg
Resources
Android resources
http://developer.android.com


Android Developers Google group
http://groups.google.com/group/android-developers


Online Tutorials
http://anddev.org
Community

           Tallinn Android Developers




http://www.meetup.com/Tallinn-Android-Developers/

Mais conteúdo relacionado

Mais procurados

Basic android development
Basic android developmentBasic android development
Basic android development
Upanya Singh
 
Android application development workshop day1
Android application development workshop   day1Android application development workshop   day1
Android application development workshop day1
Borhan Otour
 

Mais procurados (20)

Android - From Zero to Hero @ DEVit 2017
Android - From Zero to Hero @ DEVit 2017Android - From Zero to Hero @ DEVit 2017
Android - From Zero to Hero @ DEVit 2017
 
Basic android development
Basic android developmentBasic android development
Basic android development
 
Android development orientation for starters v2
Android development orientation for starters v2Android development orientation for starters v2
Android development orientation for starters v2
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfaces
 
The Glass Class - Tutorial 3 - Android and GDK
The Glass Class - Tutorial 3 - Android and GDKThe Glass Class - Tutorial 3 - Android and GDK
The Glass Class - Tutorial 3 - Android and GDK
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Android Development
Android DevelopmentAndroid Development
Android Development
 
Generating efficient APK by Reducing Size and Improving Performance
Generating efficient APK by Reducing Size and Improving PerformanceGenerating efficient APK by Reducing Size and Improving Performance
Generating efficient APK by Reducing Size and Improving Performance
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
Android Components
Android ComponentsAndroid Components
Android Components
 
Five android architecture
Five android architectureFive android architecture
Five android architecture
 
Android application development workshop day1
Android application development workshop   day1Android application development workshop   day1
Android application development workshop day1
 
Ch2 first app
Ch2 first appCh2 first app
Ch2 first app
 
Android programming basics
Android programming basicsAndroid programming basics
Android programming basics
 
Android xml-based layouts-chapter5
Android xml-based layouts-chapter5Android xml-based layouts-chapter5
Android xml-based layouts-chapter5
 
Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cycle
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
Android architecture
Android architecture Android architecture
Android architecture
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A Nutshell
 

Semelhante a Android app development basics

Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
Spike Brehm
 

Semelhante a Android app development basics (20)

android level 3
android level 3android level 3
android level 3
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and Smartphones
 
Android classes in mumbai
Android classes in mumbaiAndroid classes in mumbai
Android classes in mumbai
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
 
Invading the home screen
Invading the home screenInvading the home screen
Invading the home screen
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015
 
Gradle for Android Developers
Gradle for Android DevelopersGradle for Android Developers
Gradle for Android Developers
 
Mini curso Android
Mini curso AndroidMini curso Android
Mini curso Android
 
Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Android Froyo
Android FroyoAndroid Froyo
Android Froyo
 
Android N Highligts
Android N HighligtsAndroid N Highligts
Android N Highligts
 
Data binding 入門淺談
Data binding 入門淺談Data binding 入門淺談
Data binding 入門淺談
 
Android in practice
Android in practiceAndroid in practice
Android in practice
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
 
07_UIAndroid.pdf
07_UIAndroid.pdf07_UIAndroid.pdf
07_UIAndroid.pdf
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Android app development basics

  • 2. Hello, I’m Anton. • Developer since 2006 • Android developer since 2010 • Partner at Cannedapps
  • 3. Topics • Getting up and running with Android SDK • "Hello World!" • Deeper dive into Android application components
  • 5. • Speed, Power, Control • Standardized user experience • Ability to be on the edge • Integration
  • 6. Getting started • Java Development Kit (JDK) • IDE (Eclipse recommended) • Android SDK • Android Development Tools (ADT)
  • 7. ADT plugin for Eclipse • SDK Tools Integration • Code Editors • Layout Refactoring Support • Android Virtual Devices Manager • DDMS • ... more at http://developer.android.com/guide/developing/tools/adt.html
  • 9. Android application components • Activity • Layouts & Views • Service • Intent • AndroidManifest.xml
  • 11. Activity UI concept that represents a single screen on your app
  • 12. Activity UI concept that represents a single screen on your app DashboardActivity TrainingActivity
  • 14. DashboardActivity public class DashboardActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dashboard); preferences = PreferenceManager.getDefaultSharedPreferences(this); initViews(); initShadows(); attachEvents(); } @Override protected void onResume() { shadower.turnOn(); super.onResume(); } @Override protected void onPause() { shadower.turnOff(); super.onPause(); } .... }
  • 16. Dashboard layout <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background_gradient"> <ImageView android:layout_width="40dp" android:layout_height="36dp" android:layout_marginTop="18dp" android:layout_marginLeft="15dp" android:background="@drawable/logo_run"/> <RelativeLayout android:layout_width="fill_parent" android:layout_height="170dp" android:layout_alignParentBottom="true"> <ImageView android:id="@+id/dashboard_history_button_shadow" android:layout_width="100dp" android:layout_height="97dp" android:layout_marginLeft="110dp" android:background="@drawable/menu_history_shadow"/> <Button android:id="@+id/dashboard_history_button" android:layout_width="100dp" android:layout_height="97dp" android:layout_marginLeft="110dp" android:background="@drawable/menu_history"/> ....... </RelativeLayout> </RelativeLayout>
  • 17. Service Background process that can run for a long time
  • 18. Service Background process that can run for a long time
  • 19. Binding the Service from Activity public class TrainingActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(); Intent intent = new Intent(this, RunningSessionService.class); bindService(intent, sessionConnection, BIND_AUTO_CREATE); } @Override protected void onDestroy() { unbindService(sessionConnection); super.onDestroy(); } private ServiceConnection sessionConnection = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) {} public void onServiceConnected(ComponentName name, IBinder serviceBinding) { RunningSessionService.SessionBinder binding = (RunningSessionService.SessionBinder) serviceBinding; session = binding.getService(); } }; public void onStartTrackingClicked() { if (session != null) { session.startTracking(); } } }
  • 20. Binding the Service from Activity public class RunningSessionService extends Service { @Override public void onCreate() { super.onCreate(); init(); } @Override public int onStartCommand(Intent intent, int flags, int startId) {} @Override public void onDestroy() {} @Override public IBinder onBind(Intent intent) { binding = new SessionBinder(this); return binding; } @Override public boolean onUnbind(Intent intent) { stopSelf(); return super.onUnbind(intent); } public void startTracking() { ... } public void stopTracking() { ... } }
  • 21. Intent • An "intention" to do some work: • Broadcast a message • Start a Service • Launch an Activity • Display a web page or a list of contacts • dial a phone nr. or answer a call • etc.
  • 22. Launching next Activity with an Intent DashboardActivity TrainingActivity
  • 23. Intent public class DashboardActivity extends Activity { private void initViews() { runButton = (Button) findViewById(R.id.dashboard_run_button); historyButton = (Button) findViewById(R.id.dashboard_history_button); } private void attachEvents() { runButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(DashboardActivity.this, SelectTrackActivity.class); startActivity(intent); } }); ... } ... }
  • 25. AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cannedapps.runner" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="3"/> <application android:name="Runner" android:label="@string/app_name" android:icon="@drawable/ic_launcher_run" android:theme="@android:style/Theme.NoTitleBar"> <activity android:name="DashboardActivity" android:label="@string/app_name" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".SettingsActivity"/> <activity android:name="TracksActivity" android:screenOrientation="portrait"/> ... <service android:enabled="true" android:name=".tracking.RunningSessionService"/> </application> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> </manifest>
  • 26. AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cannedapps.runner" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="3"/> <application android:name="Runner" android:label="@string/app_name" Describe Activities & Services android:icon="@drawable/ic_launcher_run" android:theme="@android:style/Theme.NoTitleBar"> <activity android:name="DashboardActivity" android:label="@string/app_name" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".SettingsActivity"/> <activity android:name="TracksActivity" android:screenOrientation="portrait"/> ... <service android:enabled="true" android:name=".tracking.RunningSessionService"/> </application> Describe Permissions <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> </manifest>
  • 27. AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" General setup package="com.cannedapps.runner" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="3"/> <application android:name="Runner" android:label="@string/app_name" Describe Activities & Services android:icon="@drawable/ic_launcher_run" android:theme="@android:style/Theme.NoTitleBar"> <activity android:name="DashboardActivity" android:label="@string/app_name" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".SettingsActivity"/> <activity android:name="TracksActivity" android:screenOrientation="portrait"/> ... <service android:enabled="true" android:name=".tracking.RunningSessionService"/> </application> Describe Permissions <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> </manifest>
  • 28. Publishing to the Market 1. Sign up at https://market.android.com/publish - 25$ fee 2. Prepare your application Package - Test it - Build it - Sign it 3. Upload promotional material 4. Publish
  • 29. Questions? Anton Narusberg anton@cannedapps.com @antonnarusberg
  • 30. Resources Android resources http://developer.android.com Android Developers Google group http://groups.google.com/group/android-developers Online Tutorials http://anddev.org
  • 31. Community Tallinn Android Developers http://www.meetup.com/Tallinn-Android-Developers/

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n