Presentation is loading. Please wait.

Presentation is loading. Please wait.

Why Learn Android? Largest installation base of any operating system Over 20,000 Android devices exist Businesses will likely move more to device-based.

Similar presentations


Presentation on theme: "Why Learn Android? Largest installation base of any operating system Over 20,000 Android devices exist Businesses will likely move more to device-based."— Presentation transcript:

1

2 Why Learn Android? Largest installation base of any operating system Over 20,000 Android devices exist Businesses will likely move more to device-based software (and away from PCs) Understand the basic mechanics of coding for mobile platforms IIL context

3 The Project Implement an Android version of Oracle Permission Generator software Uses MVP (Model View Presenter) design pattern Business logic is already implemented and can be reused Understand how a business application could be ported to a mobile platform

4 Benefits of MVP Clear separation between business logic and presentation of data Easier to unit test Simple to refactor and add additional functionality Much easier to reuse existing code

5 System Architecture

6 Building the Model Layer C# code already contained a class OraclePermissionGeneratorDataInterfaceLayer (facade of Model functionality) Required ability to support multiple users Created a Dictionary object whose key was the user identifier, and value was an OraclePermissionGeneratorDataInterfaceLayer private Dictionary userDataRepository; No thread safety, no persistence

7 Exposing the Model Layer ‘ServiceContract’ and ‘OperationContract’ attributes [ServiceContract] public interface IOraclePermissionGeneratorWebServiceAPI { [OperationContract] String GetDefaultObjectOwner(String authenticationContext, String trackingData); [OperationContract] void SetDefaultObjectOwner(String defaultObjectOwner, String authenticationContext, String trackingData); Container classes must specify the ‘DataContract’ and ‘DataMember’ attributes Using the ServiceHost class to run the Web Service Defaults to exposing via SOAP protocol, but supports REST and others In this project, use SOAP as protocol, but JSON for serialization

8 Android Basics - Language Language looks and works exactly like Java Runs on Google ‘Dalvik’ VM, not Oracle VM Some parts of standard Java class library are not included (e.g. java.x namespace) C/C++ possible via Android NDK, C# possible via Xamarin

9 Android Basics – Development Environment Previously Eclipse was the recommended platform using ADT (Android Development Tools) plug-in Recently Google have released Android Studio, and are encouraging migration to that Started project more than one year ago, and hence developed using Eclipse

10 Android Basics – Emulator Android application must be run on real device or emulator Emulator comes with the Android Development Tools package, and includes multiple emulated devices

11 Android Basics – Project Setup Project in Eclipse is similar to standard Java project with some additions… Android libraries Generated Java code ‘res’ folder – binary resources and application XML settings ‘AndroidManifest’ file

12 Android Basics – Terminology Android vs MVP vs Windows Forms terminology Windows FormsAndroidMVP FormActivityView? ControlViewView? ?ServiceModel?

13 Android Basics – Activity Activity is a class in Android which represents a single screen in an application Android definition – ‘A single focused thing the user can do’ Derive from Activity class to create your own Activities Activity life-cycle

14 Android Basics – Service ‘Started’ service vs ‘Bound’ service For MVP context, a bound service can be used to provide the Model layer of the application “A Service is an application component that can perform long- running operations in the background and does not provide a user interface” “A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use”

15 Android Basics – Views / ViewGroups Components that allow you to display and interact with data (text, images, etc…) in an Activity… TextView ListView EditText Spinner Button Many subclasses of View included in Android API ViewGroups allow collection and arrangement of other views LinearLayout RelativeLayout

16 Android Basics – ‘R’ class and XML ‘R’ class is generated by compiler, and used to provide a reference between items defined in XML (e.g. layouts, views), and Java code Essentially a list of constant definitions ‘res’ folder in project contains XML definitions Layouts Menus Strings Dimensions Colors Styles

17 Android Basics – Intents Naming is somewhat generic… “An intent is an abstract description of an operation to be performed” Has many uses, but used in this context to… Start / show other Activities Start Services Send data to other applications (permission scripts)

18 Android Basics – Unit Testing Android tests based around JUnit Mock frameworks like Mockito can be used Recently switched to JUnit 4, but earlier versions of the Development Tools use JUnit 3 (has some minor differences) Earlier Android unit testing received quite a lot of criticism (may have improved in later versions and in Android Studio)… A lot of dependency on Android OS and core components which can be difficult to mock Creation of classes ‘hidden’ by Android (Activities, Services) Tests on the emulator – much slower than standard Java unit tests

19 Android Basics – Difficulties Context class – is a parent class of Activity Required as a parameter for many fundamental method calls (e.g. starting Intents) As Activity is considered to be the ‘View’ part of MVP it should not be referenced/used by the Model… however sometimes this cannot be avoided Was particularly problematic where there were dependencies on Android OS (saving data, sending to other applications, getting location data)

20 Next Session MVP implementation in detail Details of Android components and classes Interaction with.NET / WCF Implementing an application screen end-to-end Collecting user behavior data


Download ppt "Why Learn Android? Largest installation base of any operating system Over 20,000 Android devices exist Businesses will likely move more to device-based."

Similar presentations


Ads by Google