1 / 29

Mobile development

Mobile development. Chris Franz Systems Consultant / Advantage evangelist. May 2011. agenda. Introduction iOS Android Windows 7 Phone. introduction. Picking a platform & development environment Market share Devices (features, cost) Development community User groups

zareh
Download Presentation

Mobile development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mobile development Chris Franz Systems Consultant / Advantage evangelist May 2011

  2. agenda • Introduction • iOS • Android • Windows 7 Phone

  3. introduction • Picking a platform & development environment • Market share • Devices (features, cost) • Development community • User groups • Packages or libraries available • Cost of development • Developer license

  4. Platforms

  5. iPod Touch iPhone iPad

  6. Overview • Supported Devices • iPod Touch • iPhone • iPad • Development Tools • xCode v3.2 and Interface Builder or xCode v4 • Objective-c • Emulators for iPhone and iPad • Recommended Reading: Head First iPhone Development by Dan & Tracey Pilone

  7. Application Architecture • Follows MVC Model • Application Components • Views • Frameworks • Resources

  8. Odata Objective-c client • Available from Codeplexhttp://odataobjc.codeplex.com • Consists of Two Components • MSODataLib • oDataGen • Using With Your Project • Add location of MSODataLib source to project Header Path • Add location of libMSODataLib.a to project Library Path • Add libMSODataLib.a to project Frameworks

  9. Generating Data Classes • oDataGen creates data classes based on the metadata provided by the Advantage Web API • Syntax odatagen /uri=<data service Uri> [/out=<output file path>] [auth=windows|acs /u=username /p=password [/sn=servicenamespace [/at=appliesto] ] [/ups=yes|no] ] • Example odatagen /uri=https://localhost:6282/adsweb/example_db/1/ /out=/Users/chrisfranz/projects/tasksapp /u=adssys

  10. Example Class /** * @interface:Tasks * @Type:EntityType * @key:id* */@interface tasks_Model_Entities_Tasks : ODataObject{ /** * @Type:EntityProperty * NotNullable * @EdmType:Edm.Int32 */NSNumber *m_id; /** * @Type:EntityProperty * NotNullable * @EdmType:Edm.Decimal */NSDecimalNumber *m_rowversion; /** * @Type:EntityProperty * @EdmType:Edm.String * @MaxLength:50 * @FixedLength:true */NSString *m_name; /** * @Type:EntityProperty * @EdmType:Edm.DateTime */NSDate *m_started; /** * @Type:EntityProperty * @EdmType:Edm.DateTime */NSDate *m_finished; }

  11. Example Class @property ( nonatomic , retain , getter=getid , setter=setid )NSNumber *m_id;@property ( nonatomic , retain , getter=getrowversion , setter=setrowversion )NSDecimalNumber *m_rowversion;@property ( nonatomic , retain , getter=getname , setter=setname ) NSString *m_name;@property ( nonatomic , retain , getter=getstarted , setter=setstarted )NSDate *m_started;@property ( nonatomic , retain , getter=getfinished , setter=setfinished )NSDate *m_finished;+ (id) CreateTasksWithid:(NSNumber *)aid rowversion:(NSDecimalNumber *)arowversion;- (id) init;- (id) initWithUri:(NSString*)anUri;@end + (id) CreateTasksWithid:(NSNumber *)aid rowversion:(NSDecimalNumber *)arowversion;- (id) init;- (id) initWithUri:(NSString*)anUri;@end

  12. Initwithuri method - (id) initWithUri:(NSString*)anUri{ if(self=[super initWithUri:anUri]) { [self setBaseURI:anUri];m_OData_hasStream.booleanvalue=NO;mProperties *obj;obj=[[mPropertiesalloc]initWithEdmType:@"Edm.Int32" MaxLength:@"" MinLength:@"" FixedLength:NONullable:NOUnicode:NOConcurrencyMode:@"" FC_TargetPath:@"" FC_KeepInContent:YESFC_SourcePath:@"" FC_ContentKind:@"" FC_NsPrefix:@"" FC_NsUri:@""]; [m_OData_propertiesMapsetObject:objforKey:@"m_id"]; [obj release];obj=[[mPropertiesalloc]initWithEdmType:@"Edm.Decimal" MaxLength:@"" MinLength:@"" FixedLength:NONullable:NOUnicode:NOConcurrencyMode:@"" FC_TargetPath:@"" FC_KeepInContent:YESFC_SourcePath:@"" FC_ContentKind:@"" FC_NsPrefix:@"" FC_NsUri:@""]; [m_OData_propertiesMapsetObject:objforKey:@"m_rowversion"]; [obj release];obj=[[mPropertiesalloc]initWithEdmType:@"Edm.String" MaxLength:@"50" MinLength:@"" FixedLength:YESNullable:NOUnicode:YESConcurrencyMode:@"" FC_TargetPath:@"" FC_KeepInContent:YESFC_SourcePath:@"" FC_ContentKind:@"" FC_NsPrefix:@"" FC_NsUri:@""]; [m_OData_propertiesMapsetObject:objforKey:@"m_name"]; [obj release];obj=[[mPropertiesalloc]initWithEdmType:@"Edm.DateTime" MaxLength:@"" MinLength:@"" FixedLength:NONullable:NOUnicode:NOConcurrencyMode:@"" FC_TargetPath:@"" FC_KeepInContent:YESFC_SourcePath:@"" FC_ContentKind:@"" FC_NsPrefix:@"" FC_NsUri:@""]; [m_OData_propertiesMapsetObject:objforKey:@"m_started"]; [obj release];obj=[[mPropertiesalloc]initWithEdmType:@"Edm.DateTime" MaxLength:@"" MinLength:@"" FixedLength:NONullable:NOUnicode:NOConcurrencyMode:@"" FC_TargetPath:@"" FC_KeepInContent:YESFC_SourcePath:@"" FC_ContentKind:@"" FC_NsPrefix:@"" FC_NsUri:@""]; [m_OData_propertiesMapsetObject:objforKey:@"m_finished"]; [obj release];NSMutableArray *anEntityKey=[[NSMutableArrayalloc]init]; [anEntityKeyaddObject:@"id"]; [m_OData_entityKeysetObject:anEntityKeyforKey:@"Tasks"]; [anEntityKey release]; } return self;}

  13. Accessing ads data // Get all tasks from our service tasksData *proxy = [[tasksDataalloc]initWithUri:@"http://server:6272/adsweb/example_db/v1/" credential:nil]; QueryOperationResponse *response = [proxy execute:@"Tasks"]; _tasksArray = [response getResult]; [_tasksArray retain]; NSLog( @"got %d tasks back", [_tasksArray count] ); // Log contents of first row as an example Tasks *task = [_tasksArray objectAtIndex:1]; NSLog( @"Row1: TaskName: %@ StartDate: %@",        [task getname],        [task getstarted] ? [[task getstarted] description] : @"Not Yet" );

  14. Android android

  15. OVERVIEW • Android OS - http://www.android.com/ • Android is an open source mobile platform • Developed by the Open Handset Alliance • Strongly driven by Google • Supports multiple devices and carriers • Development – http://developer.android.com/ • Built on Linux micro kernel • Applications written in Java • SDK and emulator are free • Eclipse IDE with plug-in is used for development

  16. Application Overview • Architecture • Applications do not exit • UI can be paused, resumed, or terminated by system at anytime • A single thread handles all UI for entire device • No blocking or long calls in UI thead • Building Blocks • Activities • Service and Content Providers • Intents and Broadcast Receivers

  17. Design Patterns for DATA ACCESS • Three suggested design patterns • Content Provider API • Content Provider API with SyncAdapter • Service API • Video from Google IO 10 covers all three patterns • http://www.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html

  18. Content Provider API PATTERN Activity and CursorAdapter 1. query, insert, update, delete 7. notification 8. requery Content Provider 2. startService(intent) 5. returned data 6. update\insert Asynchronous Service Processor 3. oData request oData Client 4. GET/POST/ PUT/DELETE

  19. CONTENT PROVIDER API PATTERN • Activity and Cursor Adapter • Displays data • Use ContentObservers to receive notifications of data changes • Should re-query data when notified • Android CursorAdaptors and ListViews handle notifications automatically • Content Provider • Caches data in local SQLite database • Requests oData call from Asynchronous Service • Returns local cached data • Sends notifications when data changes

  20. CONTENT PROVIDER API PATTERN • Asyncronous Service • Sets up oData request • Checks for existing oData request • Registers the Processor callback with the thread • Starts new thread to perform oData request • Handles callback even if requesting Activity is terminated • Processor • Callback used to process results from oData query • Uses the Content Provider to update local SQLite database • Causes Content Provider to notify observers

  21. oData client • Two existing oData clients for Android • Restlethttp://www.restlet.org/ • oData4j http://code.google.com/p/odata4j/ • Both clients work with Advantage and are actively being developed • Provide slightly different licenses

  22. Example import org.restlet.ext.odata.Query; import com.advantage.example.android.quick.task.tasks.model.entities.Tasks; public class Main extends Activity { private static final String TAG = Main.class.getSimpleName(); /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TasksModelService model = new TasksModelService();; Query<Tasks> query = model.createTasksQuery("/Tasks"); try { query.execute(); } catch (Exception e) { e.printStackTrace(); } for ( Tasks task : query) { Log.i(TAG, task.getName()); } } }

  23. Windows Phone 7

  24. Windows 7 phone • Tools • Visual Studio 2010 (express is free, even for commercial use) • Windows Phone 7 Developer Tools (work in progress) • Phone emulator works very well

  25. Connecting to ads oData Proxy Class or Object - Add Service Reference dialog

  26. Accessing ads data • Use the proxy class (object) to access tables Uri serviceUri = new Uri( “http://localhost:6272/adsweb/example/v1" ); Context = new testddData( serviceUri ); IEnumerable<Customers> query; query = from c in context.Customers select c; IList<Customers> cList = query.ToList(); foreach ( Customers c in cList ) Console.WriteLine( "{0,4} {1,10} {2,10}", c.ID, c.Name, c.Location );

  27. Silverlight private void Window_Loaded( object sender, RoutedEventArgs e ) { var context = new testdd.testddData( new Uri( “http://localhost:6272/adsweb/example/v1" )); var query = from c in context.Customers select c; DataContext = query.ToList(); } <TextBox Text="{Binding Location}" Name="txtLocation" />

  28. more • Example videos on MSDN • http://msdn.microsoft.com/en-us/data/cc300162

More Related