Android app development basics
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Android app development basics

on

  • 1,755 views

 

Statistics

Views

Total Views
1,755
Views on SlideShare
1,755
Embed Views
0

Actions

Likes
1
Downloads
157
Comments
1

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

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
  • \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

Android app development basics Presentation Transcript

  • 1. Android applicationdevelopment basics Anton Narusberg
  • 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
  • 4. Android SDK
  • 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
  • 8. “Hello eSport!”
  • 9. Android application components• Activity• Layouts & Views• Service• Intent• AndroidManifest.xml
  • 10. Activity
  • 11. ActivityUI concept that represents a single screen on your app
  • 12. ActivityUI concept that represents a single screen on your appDashboardActivity TrainingActivity
  • 13. Activity lifecycle
  • 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. Dashboard layout
  • 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. ServiceBackground process that can run for a long time
  • 18. ServiceBackground process that can run for a long time
  • 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. 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. 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 IntentDashboardActivity TrainingActivity
  • 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. AndroidManifest.xml
  • 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 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. Questions? Anton Narusberganton@cannedapps.com @antonnarusberg
  • 30. ResourcesAndroid resourceshttp://developer.android.comAndroid Developers Google grouphttp://groups.google.com/group/android-developersOnline Tutorialshttp://anddev.org
  • 31. Community Tallinn Android Developershttp://www.meetup.com/Tallinn-Android-Developers/