First Steps in Android Development with Eclipse and Xamarin
-
Upload
sasha-goldshtein -
Category
Technology
-
view
1.554 -
download
1
description
Transcript of First Steps in Android Development with Eclipse and Xamarin
![Page 1: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/1.jpg)
© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
Sasha Goldshtein @goldshtnCTO, SELA Group blog.sashag.netFirst Steps in Android Development
![Page 2: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/2.jpg)
(Relevant) Android Versions
Froyo•Android 2.2
Gingerbread•Android 2.3.x
Honeycomb•Android 3.x
Ice Cream Sandwich•Android 4.0
Jelly Bean•Android 4.1-4.3
KitKat•Android 4.4
![Page 3: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/3.jpg)
Android Development Environment
Native Android
• Eclipse/Android Studio
• Android plugin for Eclipse (ADT)
• Android SDK
Xamarin (C#)
• Visual Studio• Xamarin.Android
extension• Android SDK
![Page 4: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/4.jpg)
Demo
Hello World
![Page 5: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/5.jpg)
Project Structure
srcgenres
layoutvalues
assetsAndroid X.X.XLibrariesAndroidManifest.xml
![Page 6: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/6.jpg)
What Makes an Android Application?
• Presentation layer• Derive from Activity
• Use Views• Similar to forms in
the desktop world
Activities
• Worker processes in application
• Invisible• Responsible for
updating data sources, activities, notifications
Services
• Shareable data store
• Preferred way to share data across applications
Content Providers
• Message-passing framework
• Broadcast messages to target activity/service
Intents
• Broadcast consumers
• Filtered by criteria• Listen to intents
that match the criteria
Broadcast Receivers
• Enables notifications without interrupting the current activity
• Device notification area
Notifications
![Page 7: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/7.jpg)
Resources
Resources are non-code application partsAndroid resources include images, strings, simple values, animations, themes, etc.
Best to keep separated/external from codeExternal resources are easier to maintain, upgrade, and manage (…and localize!)
Created under the res folder
![Page 8: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/8.jpg)
Layout Resources
Layouts specify the UIDecouple presentation layer from codeEnable designing UI in XML Can be referenced as any other resource from other layouts
Usually, each layout XML file = view
![Page 9: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/9.jpg)
Code and User Interface Separation
Strive to define most of the UI in XML files, and write only code in Java files
Clean code/UI separation provides flexibility and easy maintenanceMakes it easier to adjust for various types of hardware devices (similar to resource localization)
UI elements can be manipulated from code
Use findViewById to get UI element instance from code
![Page 10: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/10.jpg)
Demo
Connecting UI to Code
![Page 11: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/11.jpg)
Localization
Resources make localization easyCreate a language-specific folder structure alongside the main folder structureFolder name includes qualifiers
+ res+ values
+ strings.xml
+ values-fr+ strings.xml
+ values-fr-rCA+ strings.xml
![Page 12: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/12.jpg)
What Is an Activity?
An activity represents a screenUsing Views to provide UIExtends the Activity classTo navigate screens, start a new activity using an intent
By default, activities occupy the entire screenCan create semi-transparent/floating activities
Last-in-first-out activity stackNew activity pushes foreground activity down into stackNavigating back or finishing an activity pops from the stack the previous activity
![Page 13: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/13.jpg)
Creating Activities
Extend the Activity classThe base class presents an empty screenEncapsulates window display handling functionality
User interfaces are created using ViewsCan create UI from layout or from View-derived instances
//Using a layout resource identifier:setContentView(R.layout.main);
//Using a View-derived instance:TextView text = new TextView(this);text.setText("New text!");setContentView(text);
![Page 14: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/14.jpg)
Multiple Activities
Span a sub-activity using an IntentAll activities must be declared in the application manifest
Intent launch = new Intent(this, SecondaryActivity.class);
startActivity(launch);
<activity android:name=".SecondaryActivity"/>
![Page 15: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/15.jpg)
Layouts
Most commonly used layouts
Multiple layouts can be mixed together
Layout DescriptionFrameLayout Pins child views to the top left corner. Adding multiple
children stacks each new child on top of the previous, with each new view obscuring the last.
LinearLayout Adds each child view in a straight line, either vertically or horizontally.
RelativeLayout Enables defining the positions of each of the child views relative to each other and the screen boundaries.
TableLayout Lay out views using a grid of rows and columns.
![Page 16: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/16.jpg)
Selectors and Lists
ListView provides a convenient UI for value selection from a long list
Presents multiple items on screen
Spinner provides UI for value selection
Presents only a single value at a timeDrop-down overlay of selectable items
![Page 17: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/17.jpg)
Demo
Multiple Activities and ListView
![Page 18: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/18.jpg)
Xamarin: C# on 3 Billion Devices
Xamarin provides a .NET runtime for iOS and Android development in C#Proprietary IDE: Xamarin StudioFull Visual Studio integration
![Page 19: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/19.jpg)
Demo
Xamarin.Android
![Page 20: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/20.jpg)
Summary
Android development environmentResources, layouts, viewsIt’s just another{language, IDE, UI framework}The rest is just details: data, networking, preferences, styling, …
![Page 21: First Steps in Android Development with Eclipse and Xamarin](https://reader035.fdocuments.us/reader035/viewer/2022062418/555ae3d6d8b42a62528b541e/html5/thumbnails/21.jpg)
QuestionsSasha Goldshtein @goldshtnCTO, SELA Group blog.sashag.net