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

Android app development basics

on

  • 1,686 views

 

Statistics

Views

Total Views
1,686
Slideshare-icon Views on SlideShare
1,686
Embed Views
0

Actions

Likes
1
Downloads
156
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

11 of 1

  • 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 Android app development basics Presentation Transcript

  • 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• 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
  • 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 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>
  • 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(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 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() { ... }}
  • 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 IntentDashboardActivity TrainingActivity
  • 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); } }); ... } ...}
  • 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 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
  • Questions? Anton Narusberganton@cannedapps.com @antonnarusberg
  • ResourcesAndroid resourceshttp://developer.android.comAndroid Developers Google grouphttp://groups.google.com/group/android-developersOnline Tutorialshttp://anddev.org
  • Community Tallinn Android Developershttp://www.meetup.com/Tallinn-Android-Developers/