Building Applications with ArcGIS Runtime SDK for Android - Esri
Transcript of Building Applications with ArcGIS Runtime SDK for Android - Esri
![Page 1: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/1.jpg)
Building Applications with ArcGIS Runtime SDK for Android—Part II
Will Crick Dan O’Neill
![Page 2: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/2.jpg)
Agenda
• Intro • Connected editing summary • Offline capabilities
- Local features - Geometry Engine
• Platform integration • Accessing content from ArcGIS Online/Portal • Best practice
- Layer performance - UI thread - Device support
![Page 3: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/3.jpg)
Intro
![Page 4: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/4.jpg)
Who are we all?
• Who are you? • Who are we?
![Page 5: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/5.jpg)
ArcGIS 10 — A Complete System
Easier More Powerful and Everywhere
Cloud
Enterprise
Local
• Discover • Create • Manage • Visualize • Analyze • Collaborate
Mobile
Desktop
Web
![Page 6: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/6.jpg)
Runtime SDKs
Native ArcGIS Runtime SDKs
iOS Android Windows Phone
Windows Mobile
Windows Linux
Runtime SDK • Objective C
Runtime SDK • Java
Runtime SDK • Silverlight
Runtime SDK • .NET
Runtime SDK • WPF, Java
Runtime SDK • Java
Core Runtime
![Page 7: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/7.jpg)
Runtime Architecture
Windows Mobile
Windows Phone
Remote Server
Geocoding Mapping
GP Editing
Runtime Core
Tile Package
OpenGL
GPS
DirectX
Messaging Advanced Symbology
Server Sync Offline Routing
Spatial analysis Offline Geocoding
Native platform
capabilities iOS Android
WPF Java Local Server
Geocoding Mapping
GP Editing
![Page 8: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/8.jpg)
SDK Release Status
• ArcGIS for Android SDK - 1.0 – current (12/11) – 1800 unique installs - 1.1 to be released next week
- Multiple maps - Advanced symbology/message processing - ArcGIS Online/Portal & webmap loading - Group layer - Improved secure service framework - Supports ADT r17
- 1.x/2.0 summer
![Page 9: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/9.jpg)
Connected editing
![Page 10: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/10.jpg)
Editing
• AttributeEditor & GeometryEditor samples in SDK • Uses Feature Service
- Same model as other webapis - applyEdits()
• AttributeEditor sample
- check field data types - Data entry - Validation
![Page 11: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/11.jpg)
Geometry Editing Sample
• Uses a “sketch” graphics layer - Uses MapOnTouchListener
- Implements tap and drag events
• Track local edit history yourself • Uses local GeometryEngine
- No server call
![Page 12: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/12.jpg)
FeatureLayer.applyEdits() method
• Aynchronous method - CallbackListener / AsynTask - Callback tells success for each feature
• applyEdits(adds, deletes, updates, callback)
• Attribute updates - Graphic - only changed attributes & ID
![Page 13: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/13.jpg)
Offline capabilities
![Page 14: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/14.jpg)
What can you do offline today?
In memory feature layers
Query attributes offline
Store features in ArcGIS db
Base maps Geometry operations Message Processing
Advanced symbology
Sync offline data with server
Routing Geocoding
See the futures section at the end for news on this stuff!
![Page 15: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/15.jpg)
Adding base maps
• As seen in part I • Local tiled layers
- compact caches – from 10.0 server - NOT 10.1 TPKs [yet]
- Fat32 4GB file size limit
baseMapLayer = new ArcGISLocalTiledLayer(”file:///mnt/sdcard/<CacheName>/Layers", false);
![Page 16: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/16.jpg)
Offline features
A • Use in memory “feature collection” Feature Layer
- Feature set [array of features] - Layer definition [json from a feature service]
• Change features using: - addGraphic() / removeGraphic() methods - applyEdits() method [new in 1.1 for feature collection!]
• Write features to/from disk in json [new in 1.1!] B • Graphics layers
- Add/remove graphics C
• Advanced Symbology - Process messages
![Page 17: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/17.jpg)
Offline features code examples
<!—strings.xml--> <string name="config.windturbine.layer.definition"> {\"currentVersion\":10.01,\"id\":0,\"name\":\"Wind Turbine\”… </string>
featureLayer.addGraphics(graphics); //or Graphic[] graphics = new Graphic[ g ]; featureLayer.applyEdits( //adds graphics, //updates, //deletes);
//Java class turbinesFeatureLayer = new ArcGISFeatureLayer(R.string. config.windturbine.layer.definition, FeatureSet, null);
Create the layer…
(Demo app is different, creates layer then loads json features, then adds features) Add/edit features…
![Page 18: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/18.jpg)
to/fromJson
• Jackson JsonParser • Serialize to disk
- FeatureSet.toJson(); - String - JsonGenerator.writeRawValue();
• Read from disk - Passed to activity in a bundle - FeatureSet.fromJson(jsonParser, hasSpatialRef);
File jsonFile = bladeRunnerApp.getJSONFile(BladeRunnerApplication.teamAreasName); JsonFactory jsonFactory = new JsonFactory(); JsonParser jsonParser = jsonFactory.createJsonParser(jsonFile); FeatureSet featureSet = FeatureSet.fromJson(jsonParser, true);
![Page 19: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/19.jpg)
Will Crick
Blade Runner demo
![Page 20: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/20.jpg)
Message Processing
• Add features to the map via a message - Radio/UDP/wifi - Different actions, add/update/delete - Different message types - Requires an initialized group layer
• Support for advanced symbology - Based on symbol packages (dictionary .dat files) - 2525c Military symbology (new in 1.1) - Build your own custom dictionary (future release)
- Needs desktop support
![Page 21: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/21.jpg)
Message Processor Workflow
• MessageProcessor processes a message from an external resource
• DictionaryType enum dictates message format • DictionaryType is backed by a resource bundle
- Dictionary data file - Message file types
• MessageProcessor bound to a Group Layer - Used to display, update, and remove MultilayerSymbol
![Page 22: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/22.jpg)
Message Processing Code example
MapView map = (MapView)findViewById(R.id.map); final GroupLayer groupLayer = new GroupLayer(); map.addLayer(groupLayer); try { MessageProcessor processor = new MessageProcessor(DictionaryType.Mil2525C, groupLayer); } catch (FileNotFoundException e) { e.printStackTrace(); }
Create a MessageProcessor Object
![Page 23: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/23.jpg)
Message Processing Code example
// Message creation Message lmessage = new Message(); UUID luuid = UUID.randomUUID(); lmessage.setID(luuid.toString()); lmessage.setProperty("_Type", "position_report"); lmessage.setProperty("_Action", "update"); String controlpoints = x1 + "," + y1; lmessage.setProperty("_Control_Points", controlpoints); lmessage.setProperty("sic", "SFGPUCRRL--E---"); lmessage.setProperty("_WKID", "3857"); lmessage.setProperty("UniqueDesignation", "2020"); // process message and add point processor.processMessage(lmessage);
Create a Message object Process it!
![Page 24: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/24.jpg)
Update Graphics
• Get GraphicLayer from GroupLayer • Get Graphic from GraphicsLayer • Get Geometry from Graphic • Set Property with update • Process messsage
Message message = processor.createMessageFrom(gr); String controlPoints = (String)message.getProperty( MessageHelper.MESSAGE_2525C_CONTROL_POINTS_PROPERTY_NAME); if (targetcontrolpt !=null) { message.setProperty( MessageHelper.MESSAGE_2525C_CONTROL_POINTS_PROPERTY_NAME, targetcontrolpt.getX() + "," + targetcontrolpt.getY()); } message.setProperty("_Action", "update"); processor.processMessage(message);
![Page 25: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/25.jpg)
Dan O’Neill
Message processing demo
![Page 26: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/26.jpg)
Platform integration Will Crick
![Page 27: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/27.jpg)
Using the GPS
• Wraps Android Location Service • Adds useful functions
- Symbol - Accuracy [changed at 1.1] - Auto pan
LocationService ls = map.getLocationService(); ls.setSymbol(symbol); ls.setAccuracyCircleOn(true); ls.setBearing(false);
(Demo app uses simulated location to make things easier!)
![Page 28: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/28.jpg)
Compass sensor integration
• Use SensorManager to get access to sensors • Create Sensor object ( TYPE_ORIENTATION /
getOrientation() ) • Register SensorEventListener with SensorManager
public void onSensorChanged(SensorEvent event) { sensorValues = event.values; map.setRotationAngle(sensorValues[0]); }
![Page 29: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/29.jpg)
Bluetooth devices
• Laser range finder to add a point using an offset
• Get BlueToothDevice from BlueToothAdapter(String address)
• Create a custom service (BlueToothSerialService) - reads bytes from a socket - send bytes in a message to MapViewActivity Handler
- Converts to string buffer - Reads LSR sentence
- Uses local method/ (maths) to create point from offset - PointFromOffset will be in future version of SDK
![Page 30: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/30.jpg)
Blade Runner app code
![Page 31: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/31.jpg)
ArcGIS Portal (new in 1.1)
Dan O’Neill
![Page 32: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/32.jpg)
Portal API basics
• Organization - Part of portal created for specific entity - Configurable site - Invite and manage users
• Groups and Users - Collaboration with other portal users - Exchange content related to activities/projects
![Page 33: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/33.jpg)
Accessing a Portal
• Portal Class - Entry point - Instantiate with credential or as guest - 2 cases
- 1. Organization account - 2. Portal
- If credential provided automatically connects to Organization account
![Page 34: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/34.jpg)
Workflow
• Create a Portal • Get the feature group query list with portalinfo • Loop through the list of queries and retrieve each
group • For each group get the title and thumbnail • Update the View with the results
![Page 35: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/35.jpg)
Portal connection
//set up portal portalUrl = "https://csf.maps.arcgis.com/"; credentials = new UserCredentials(); credentials.setUserAccount("mobile_org", "dev.team"); //create a new instance of portal Portal.newInstance(portalUrl, credentials, new PortalListener<Portal>() { @Override public void onError(Throwable e) { e.printStackTrace(); } @Override public void onCallback(Portal portal) { ... });
Create the portal with credentials and Portal URL
![Page 36: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/36.jpg)
Search Portal
PortalQueryParams queryParams = new PortalQueryParams(); queryParams.setQueryForItemsInGroup(groupId); // You can also create your custom PortalQueryParams object PortalQueryParams queryParamS = new PortalQueryParams(); // Once you have the query parameter string, // you can make the query on the portal. portal.findItems(queryParams, portalListener);
• Construct query string - PortalQueryParams methods return query strings - findItemsWithQueryParams queries items and groups
• Find list of items in a group
![Page 37: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/37.jpg)
Dan O’Neill
ArcGIS Portal demo
![Page 38: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/38.jpg)
Best Practice
![Page 39: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/39.jpg)
ArcGIS for Android Layer performance • Try to minimize traffic
- Requests are expensive - Processing of results cost
• ArcGISFeatureLayer - types - Snapshot / feature collection - On Demand - Selection
• TileLayer (ArcGIS, Bing) - Static - Also have dynamic access
• Dynamic map service layer - Image only
• ArcGISLocalTiledLayer - No network requests!
Combine together
![Page 40: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/40.jpg)
The importance of the UI Thread
• Work with Views on the UI Thread • Async methods are common
- Run in other threads
• Options - AsyncTask
- Handler() – bound to creation thread - Processed in a queue - messages & runnables
- View.runOnUiThread(new runnable(){…})
- ExecutorService
- Threads
![Page 41: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/41.jpg)
OS support
• 2.2 25%!
![Page 42: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/42.jpg)
Device & OS support
• Single app deployment - UI = fragments/different views
• Compatibility libraries - Fragments 1.6+ - Action Bar 3.0+
• Some devices don’t have features - cameras/gps
• Deployment - Manifest settings are really important
• Localisation means global…
![Page 43: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/43.jpg)
The future
![Page 44: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/44.jpg)
Future releases
• Playing iOS catchup J - Open Streetmap layer - NAServer task - Wrap around - Navigation modes
• 10.1 server support - Editor tracking - Replica service
- Also local data storage and a sync api - Related tables!!!
• Online features - Wms/wmts/kml - Csv by ref
• Runtime…………..
![Page 45: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/45.jpg)
Summary info
• Where to get more info - Resource centre - http://resources.arcgis.com/content/arcgis-
android/sdk - Blog -
http://blogs.esri.com/esri/arcgis/category/mobile/ - Forum - http://forums.arcgis.com/forums/139-ArcGIS-Runtime-SDK-for-
Android - Last resort [email protected]
• Where to get code - We will post demo app to arcgis online android group shortly - http://www.arcgis.com/home/group.html?owner=willcrick&title=Android
![Page 46: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/46.jpg)
Questions??
• All yours….
![Page 47: Building Applications with ArcGIS Runtime SDK for Android - Esri](https://reader031.fdocuments.us/reader031/viewer/2022020913/62034a6424f6b61e9c664903/html5/thumbnails/47.jpg)