0
Android applicationdevelopment 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• ...
“Hello eSport!”
Android application         components• Activity• Layouts & Views• Service• Intent• AndroidManifest.xml
Activity
ActivityUI concept that represents a single screen on your app
ActivityUI concept that represents a single screen on your appDashboardActivity                TrainingActivity
Activity lifecycle
DashboardActivitypublic class DashboardActivity extends Activity {    @Override    public void onCreate(Bundle savedInstan...
Dashboard layout
Dashboard layout<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/an...
ServiceBackground process that can run for a long time
ServiceBackground process that can run for a long time
Binding the Service from Activitypublic class TrainingActivity extends Activity {    @Override    public void onCreate(Bun...
Binding the Service from Activitypublic class RunningSessionService extends Service {    @Override    public void onCreate...
Intent•   An "intention" to do some work:    •   Broadcast a message    •   Start a Service    •   Launch an Activity    •...
Launching next Activity with an IntentDashboardActivity         TrainingActivity
Intentpublic class DashboardActivity extends Activity {    private void initViews() {      runButton = (Button) findViewBy...
AndroidManifest.xml
AndroidManifest.xml<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/andro...
AndroidManifest.xml<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/andro...
AndroidManifest.xml<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/andro...
Publishing to the Market1. Sign up at https://market.android.com/publish     - 25$ fee2. Prepare your application Package ...
Questions?   Anton Narusberganton@cannedapps.com   @antonnarusberg
ResourcesAndroid resourceshttp://developer.android.comAndroid Developers Google grouphttp://groups.google.com/group/androi...
Community           Tallinn Android Developershttp://www.meetup.com/Tallinn-Android-Developers/
Upcoming SlideShare
Loading in...5
×

Android app development basics

1,681

Published on

Published in: Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
1,681
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
178
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Android app development basics"

    1. 1. Android applicationdevelopment basics Anton Narusberg
    2. 2. Hello, I’m Anton.• Developer since 2006• Android developer since 2010• Partner at Cannedapps
    3. 3. Topics• Getting up and running with Android SDK• "Hello World!"• Deeper dive into Android application components
    4. 4. Android SDK
    5. 5. • Speed, Power, Control• Standardized user experience• Ability to be on the edge• Integration
    6. 6. Getting started• Java Development Kit (JDK)• IDE (Eclipse recommended)• Android SDK• Android Development Tools (ADT)
    7. 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
    8. 8. “Hello eSport!”
    9. 9. Android application components• Activity• Layouts & Views• Service• Intent• AndroidManifest.xml
    10. 10. Activity
    11. 11. ActivityUI concept that represents a single screen on your app
    12. 12. ActivityUI concept that represents a single screen on your appDashboardActivity TrainingActivity
    13. 13. Activity lifecycle
    14. 14. DashboardActivitypublic 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(); } ....}
    15. 15. Dashboard layout
    16. 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. 17. ServiceBackground process that can run for a long time
    18. 18. ServiceBackground process that can run for a long time
    19. 19. Binding the Service from Activitypublic 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. 20. Binding the Service from Activitypublic 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. 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. 22. Launching next Activity with an IntentDashboardActivity TrainingActivity
    23. 23. Intentpublic 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); } }); ... } ...}
    24. 24. AndroidManifest.xml
    25. 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. 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. 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. 28. Publishing to the Market1. Sign up at https://market.android.com/publish - 25$ fee2. Prepare your application Package - Test it - Build it - Sign it3. Upload promotional material4. Publish
    29. 29. Questions? Anton Narusberganton@cannedapps.com @antonnarusberg
    30. 30. ResourcesAndroid resourceshttp://developer.android.comAndroid Developers Google grouphttp://groups.google.com/group/android-developersOnline Tutorialshttp://anddev.org
    31. 31. Community Tallinn Android Developershttp://www.meetup.com/Tallinn-Android-Developers/
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×