Android Development with ArcGIS Server<br />Esri Dev Meet Up<br />Charlotte, NC<br />October 19th, 2010<br />Jim Tochterma...
What is Android?<br />Software stack for mobile devices, formally introduced in 2008<br />Unlike other mobile devices, not...
Why choose Android over iPhone?<br />Customers:<br />iPhone cost was prohibitive for widespread deployment<br />No Objecti...
Why develop with Android?<br />Background Services<br />Event driven model that works silently while other applications ar...
Pros & Cons with Android Development<br />Pros:<br />Good Development Tools and Samples<br />No App Store / Market Require...
Where Do I Get Started?<br />Download Eclipse (or my preference MotoDev Studio)<br />http://www.eclipse.org/downloads<br /...
Design Considerations For Mobile Devices<br />Low Processing Speed<br />Optimize code to run quick and efficiently<br />Li...
How do I use ArcGIS Server with Android?<br />ArcGIS API for Android is coming!  Finally!!<br />http://resources.arcgis.co...
How do I use ArcGIS Server with Android now!?<br />Sign up for the Early Adopter Program – OR -<br />arcgis4android@esri.c...
Demo…<br />Integrating ArcGIS Server Data & Services with Google Maps API (via REST API)<br />
Creating Map Overlay (MainActivity.java)<br />public class MainActivity extends MapActivity implements OnSharedPreferenceC...
Creating Map Overlay (WMSOverlay.java)<br />public class WMSOverlay extends Overlay<br />{<br />	private final static Stri...
Creating Map Overlay (WMSLoader.java)<br />public class WMSLoader<br />{<br />	public static String TAG = "WMSLoader";<br ...
Creating Data via REST API (MainActivity.java)<br />public class MainActivity extends MapActivity implements OnSharedPrefe...
Creating Data via REST API (DataCollectionActivity.java)<br />public class DataCollectionActivity extends Activity <br />{...
Creating Data via REST API (NoteCreateActivity.java)<br />public class NoteCreateActivity extends Activity<br />{<br />	st...
Demo…<br />Sneak Peek ofApp Built w/ ArcGIS for Android API<br />
Questions?<br />
Want More Information?<br />http://developer.android.com<br />http://resources.arcgis.com/content/arcgis-android/about<br ...
Upcoming SlideShare
Loading in …5
×

Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC

2,681 views
2,559 views

Published on

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,681
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC

  1. 1. Android Development with ArcGIS Server<br />Esri Dev Meet Up<br />Charlotte, NC<br />October 19th, 2010<br />Jim Tochterman, VP - Research & Development<br />www.bcs-gis.com<br />www.facebook.com/bcsgis<br />www.twitter.com/bcsgis<br />
  2. 2. What is Android?<br />Software stack for mobile devices, formally introduced in 2008<br />Unlike other mobile devices, not a proprietary OS<br />iOS<br />Palm OS<br />Blackberry OS<br />Combination of three (3) components<br />Free, open source OS for mobile devices<br />Free, open source development environment for creating mobile applications<br />Devices that run the Android OS and the applications created for it<br />http://developer.android.com/guide/basics/what-is-android.html<br />
  3. 3. Why choose Android over iPhone?<br />Customers:<br />iPhone cost was prohibitive for widespread deployment<br />No Objective-C / Cocoa developers on staff<br />No Mac hardware available<br />Technical Limitations / General Annoyances:<br />GSM coverage is not good in the Southeast (even in Urban Areas) <br />iPhone did not support “backgrounding” (at the time)<br />Deployment Hurdles (App Store, Code Signing, etc.)<br />Xcode is quite possibly the worst IDE ever!<br />Comfort Level:<br />If you do Flex or Java development already the tools are very similar!<br />
  4. 4. Why develop with Android?<br />Background Services<br />Event driven model that works silently while other applications are being used.<br />Shared Data & Inter-Process Communication<br />Applications can exchanges messages, perform processing, and share data.<br />Widgets & Live Folders<br />Allows you to create windows into your applications from your device’s home screen.<br />Application Equality<br />No differentiation between native applications and those developed by third parties.<br />
  5. 5. Pros & Cons with Android Development<br />Pros:<br />Good Development Tools and Samples<br />No App Store / Market Requirement!<br />Build and Deploy with Dropbox if you feel like it<br />Cons:<br />Terminology! What in the hell is an Activity and a Intent!? (The names can seem strange, but based upon what they do)<br />More work to make a “Pretty” app<br />
  6. 6. Where Do I Get Started?<br />Download Eclipse (or my preference MotoDev Studio)<br />http://www.eclipse.org/downloads<br />http://developer.motorola.com/docstools/motodevstudio/download<br />Download Android ADT and SDK<br />http://developer.android.com/sdk/index.html<br />Start Playing!<br />
  7. 7. Design Considerations For Mobile Devices<br />Low Processing Speed<br />Optimize code to run quick and efficiently<br />Limited storage & memory<br />Minimize application size<br />Reuse and share data (using databases & saved files)<br />Limited bandwidth & high latency<br />Allow for slow, intermittent network connections<br />Limited Battery Life<br />Avoid expensive operations where/when possible<br />Limit sensor access when not being used<br />
  8. 8. How do I use ArcGIS Server with Android?<br />ArcGIS API for Android is coming! Finally!!<br />http://resources.arcgis.com/content/arcgis-android/api<br />
  9. 9. How do I use ArcGIS Server with Android now!?<br />Sign up for the Early Adopter Program – OR -<br />arcgis4android@esri.com<br />Use ArcGIS Server REST API & Web Services!<br />WMS Service provides Map Tiles for Overlays<br />Feature Service provides ability to retrieve and/or edit data<br />
  10. 10. Demo…<br />Integrating ArcGIS Server Data & Services with Google Maps API (via REST API)<br />
  11. 11. Creating Map Overlay (MainActivity.java)<br />public class MainActivity extends MapActivity implements OnSharedPreferenceChangeListener<br />{<br /> private final static String TAG = "MainActivity";<br />MyMapViewmyMapView;<br />MapControllermapController;<br />LocationManagerlocationManager; <br />MyCustomLocationOverlaymyLocationOverlay;<br />WMSOverlayAtlanticStormsOverlay;<br /> …<br />AtlanticStormsOverlay = new WMSOverlay("http://aws.bcs-gis.com/arcgis/services/Storms/Atlantic/MapServer/WMSServer?", layerIds, myMapView);<br />overlays.add(AtlanticStormsOverlay );<br /> …<br />}<br />
  12. 12. Creating Map Overlay (WMSOverlay.java)<br />public class WMSOverlay extends Overlay<br />{<br /> private final static String TAG = ”WMSOverlay";<br />WMSLoaderwmsClient;<br /> …<br /> public WMSOverlay(Stringurl, String layers, MapViewmapView)<br /> {<br /> …<br />wmsClient = new WMSLoader(url, layers);<br />intleftLongitude = mapView.getMapCenter().getLongitudeE6() - mapView.getLongitudeSpan()/2;<br />intrightLongitude = mapView.getMapCenter().getLongitudeE6()+ mapView.getLongitudeSpan()/2;<br />intupperLatitude = mapView.getMapCenter().getLatitudeE6() + mapView.getLatitudeSpan()/2;<br />intlowerLatitude = mapView.getMapCenter().getLatitudeE6() - mapView.getLatitudeSpan()/2;<br />GeoPointupperLeft = new GeoPoint(upperLatitude,leftLongitude);<br />GeoPointlowerRight = new GeoPoint(lowerLatitude,rightLongitude);<br />image = wmsClient.loadMap(mapView.getWidth(), mapView.getHeight(), upperLeft, lowerRight);<br /> }<br />}<br />
  13. 13. Creating Map Overlay (WMSLoader.java)<br />public class WMSLoader<br />{<br /> public static String TAG = "WMSLoader";<br /> public String serverUrl;<br /> public String layerIds;<br /> …<br />public Bitmap loadMap(int width, int height, GeoPointul, GeoPointlr) {<br /> URL url = null;<br /> try {<br />url = new URL(String.format(serverUrl +<br /> "LAYERS=" + layerIds + "&TRANSPARENT=true&FORMAT=image/ png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/ vnd.ogc.se_inimage&SRS=EPSG:4326" + "" +<br /> "&BBOX=%f,%f,%f,%f&WIDTH=%d&HEIGHT=%d", ul.getLongitudeE6()/1E6, lr.getLatitudeE6()/1E6, lr.getLongitudeE6 ()/1E6, ul.getLatitudeE6()/1E6, width, height));<br /> …<br /> Bitmap image = BitmapFactory.decodeStream(input);<br /> return image;<br />}<br />}<br />
  14. 14. Creating Data via REST API (MainActivity.java)<br />public class MainActivity extends MapActivity implements OnSharedPreferenceChangeListener<br />{<br />…<br /> @Override<br /> public booleanonCreateOptionsMenu(Menu menu) <br /> {<br />boolean result = super.onCreateOptionsMenu(menu);<br /> …<br />menu.add(0, 996, Menu.NONE, "SITREP Notes").setIcon(android.R.drawable.ic_menu_myplaces);<br />…<br /> }<br /> @Override<br /> public booleanonOptionsItemSelected(MenuItem item) <br /> {<br />super.onOptionsItemSelected(item);<br />Intent mapIntent = new Intent(Intent.ACTION_VIEW);<br /> switch (item.getItemId())<br /> {<br /> …<br />case (996) :<br /> Intent dca = new Intent(this, DataCollectionActivity.class);<br />startActivityForResult(dca, 996);<br /> return true;<br /> …<br /> }<br /> // Return false if you have not handled the menu item.<br /> return false;<br /> } <br />}<br />
  15. 15. Creating Data via REST API (DataCollectionActivity.java)<br />public class DataCollectionActivity extends Activity <br />{<br /> static final String TAG = "DataCollectionActivity"; <br /> …<br />pointButton.setOnClickListener(newOnClickListener() {<br /> public void onClick(Viewv) {<br /> //Ask the user if they want to post report <br /> new AlertDialog.Builder(DataCollectionActivity.this) <br /> .setIcon(android.R.drawable.ic_dialog_alert) <br /> .setTitle("Post Note") <br /> .setMessage("Are you sure you want to post this note?") <br /> .setPositiveButton("Yes", new DialogInterface.OnClickListener() { <br /> public void onClick(DialogInterface dialog, int which) { <br /> Bundle bundle = new Bundle();<br />bundle.putString("type", pointSpinner.getSelectedItem().toString());<br />bundle.putString("reportdatetime", deviceData.getReportDateTime());<br />bundle.putString("comments", commentsEditText.getText().toString());<br />Intent intent = new Intent(Intent.ACTION_VIEW); <br />intent.putExtras(bundle);<br />intent.setClassName("com.bcs.android.sitrep", "com.bcs.android.sitrep.NoteCreateActivity");<br />intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); <br />startActivity(intent); <br /> } <br /> }) <br /> .setNegativeButton("No", null) <br /> .show(); <br /> …<br />}<br />
  16. 16. Creating Data via REST API (NoteCreateActivity.java)<br />public class NoteCreateActivity extends Activity<br />{<br /> static final String TAG = "NoteCreateActivity"; <br />private String serverUrl = "http://devweb.bcs-gis.com/arcgis/rest/services/SITREP_Notes2/FeatureServer/0/addFeatures";<br /> …<br />String attrString = ",'attributes':{";<br />attrString = attrString + "'TYPE':'" + type + "'," + "'RPTDATETIME':'" + reportdatetime + "', " + "'SUMMARY':'" + comments + "'";<br />attrString = attrString + "}";<br /> String coordString = "[{'geometry':{";<br />coordString = coordString + "'x':" + loc.getLongitude() + ",'y':" + loc.getLatitude();<br />coordString = coordString + "}" + attrString + "}]";<br />HttpClienthttpclient = new DefaultHttpClient();<br />HttpPosthttppost = new HttpPost(serverUrl);<br /> try {<br /> // Add your data<br /> List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);<br />nameValuePairs.add(newBasicNameValuePair("features", coordString));<br />httppost.setEntity(newUrlEncodedFormEntity(nameValuePairs));<br /> // Execute HTTP Post Request<br />httpResponse = httpclient.execute(httppost);<br />…<br />}<br />
  17. 17. Demo…<br />Sneak Peek ofApp Built w/ ArcGIS for Android API<br />
  18. 18. Questions?<br />
  19. 19. Want More Information?<br />http://developer.android.com<br />http://resources.arcgis.com/content/arcgis-android/about<br />WROX Book: Professional Android 2 Application Development (Meier)<br />ISBN#: 978-0-470-56552-0<br />jtoch@bcs-gis.com<br />twitter.com/jtochterman<br />

×