building applications with arcgis runtime sdk for android - esri

47
Building Applications with ArcGIS Runtime SDK for Android—Part II Will Crick Dan O’Neill

Upload: others

Post on 09-Feb-2022

15 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

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

Intro

Page 4: Building Applications with ArcGIS Runtime SDK for Android - Esri

Who are we all?

• Who are you? • Who are we?

Page 5: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

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

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

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

Connected editing

Page 10: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

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

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

Offline capabilities

Page 14: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

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

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

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

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

Will Crick

Blade Runner demo

Page 20: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

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

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

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

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

Dan O’Neill

Message processing demo

Page 26: Building Applications with ArcGIS Runtime SDK for Android - Esri

Platform integration Will Crick

Page 27: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

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

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

Blade Runner app code

Page 31: Building Applications with ArcGIS Runtime SDK for Android - Esri

ArcGIS Portal (new in 1.1)

Dan O’Neill

Page 32: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

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

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

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

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

Dan O’Neill

ArcGIS Portal demo

Page 38: Building Applications with ArcGIS Runtime SDK for Android - Esri

Best Practice

Page 39: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

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

OS support

• 2.2 25%!

Page 42: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

The future

Page 44: Building Applications with ArcGIS Runtime SDK for Android - Esri

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

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

Questions??

• All yours….

Page 47: Building Applications with ArcGIS Runtime SDK for Android - Esri