Transcript

00:01Alright, guys. Welcome to the Building Applications for ArcGIS Runtime SDK for Windows Phone, part II.

00:05So this is really the advanced session for building Windows Phone-based applications using our SDK.

00:11My name is Rex Hansen, product lead for Microsoft clients at Esri.

00:16I'm joined by Eager Ip, lead dev. for Windows Phone, and Kylie Donia, the lead product engineer for Windows Phone as well.

00:30But we're going to get right to the demos as soon as we possibly can, so just a brief look at the agenda here.

00:36We're actually just going to do a quick discussion on Metro, just to get an idea of the new design interface...

00:38Alright, so I'm going to take us through just a brief intro.

00:41...or the design paradigm that really is the foundation for a lot of the application building...

00:47...building an application, designing an application for Windows Phone specifically...

00:51...and then also something that you're going to see in Windows 8 actually, too, so this might be interesting...

00:55...to get kind of a background on that.

00:57Something to keep in mind is that you might see some of the Metro design and the Metro workflow in the apps that are built today.

01:04So keep an eye out for that. It might be something to look for.

01:07Then we'll finish with a little Q&A on some of the stuff that we saw in the demo today.

01:13Now, if you go to Microsoft's site, they have a nice little PDF actually on the Metro design...

01:19...and the actual document itself is Metro, right.

01:23Minimalistic. They start off with a nice statement here that talks about Metro as our design language, right.

01:27We call it Metro because it's modern and clean.

01:32And so it's kind of interesting that the document itself is Metro.

01:34It's very minimalistic.

01:36It is also quite crisp.

01:39So really that kind of highlights a lot of the functionality that's...if we hit some of the details of what underlies Metro...

01:47...is it's not just a code name for, you know, the Windows Phone user experience and application design...

01:55...which emphasizes that clean, crisp user experience; intuitive; personal, right; deliberate.

02:03But it's made up of a variety of different components, right.

02:05And then all these components have something technical that backs them, right.

02:09So we have a set of themes.

02:10We start in the upper left. We have a set of themes.

02:12Really, these themes really work out to be a set of resources, right, a set of styles and templates that are actually used...

02:19...to really personalize the look and feel of an application that you build on Windows Phone.

02:23Same thing for Windows 8, a Windows 8 application, right.

02:26These are common themes, common threads that are used across application development in general for the Metro-style applications.

02:35Static resources, right.

02:36This is a technical way for actually working with those resources specifically.

02:40There's a common set of resources and schemes and styles that you can use.

02:44Page anatomy. Page anatomy applies to the Metro design, the look and feel by offering different layouts, right.

02:51So a panorama of pages, maybe working with a set of application tabs that have maybe a pivot experience...

02:59...and you might see that experience within, let's say, our ArcGIS application, it's in the marketplace.

03:05Basically, different ways of interacting with content, the clean, crisp content that happens to be in your app.

03:10You might have a single page utility app.

03:12So there's really a couple different types of Metro applications as far as page anatomy is designed.

03:21Within those pages, you might see something like a title, might see something like an application bar.

03:26That application bar might have menu items, right, and there's a sort of a refined standard for how that...

03:33...for how applications are built and how they flow.

03:36Next option here is animations and transitions.

03:38Really, this is a...if you're thinking about animation, it may be associated with a user interaction, but it's really local.

03:47It's defined to give the user feedback, but it needs to be responsive and effective, right, and clean.

03:54Basically trying to transition a user from one view to another might be a good animation...

04:00...to indicate that something's happening and be deliberate about it.

04:05The transition itself is usually a response to user action, right.

04:09So you're providing some sort of feedback to teach the user how to use the application, right.

04:15So this transition allows you to respond to a deliberate user action, right.

04:19And so that should be a common flow within the application within the Metro design experience.

04:25There's an execution model, and this is an underlying execution model for how the applications work, how they perform...

04:33...when they're active, when they're in the background, when they're actually a tombstoned...

04:36...and when they're brought back to the foreground, how they run in the background...

04:41...and what you have access to and what you can do.

04:44So working with the application in page state and persisting that application in page state.

04:49Working with application and page events, right, and being able to manage that within the tombstoning concept.

04:57Matter of fact, Eager, I think, is going to touch on the execution model in more detail here.

05:00We'll see a brief graph, what that looks like.

05:04And lastly, the form factor, right.

05:07So, in general, what we've seen with Windows Phone is we have a very standard...fairly standard form factor...

05:12...where we have a common set of hardware controls that we can assume are generally there, whether it happens to be a...

05:18...obviously a multitouch screen or working with a common set of buttons on the interface on the hardware...

05:24...the hardware device itself, an 800 by 400 pixel display, right.

05:29So there's some common characteristics of the form factor when working on a Windows Phone device.

05:40Obviously, just recently, with the Tango update, we're expanding that form factor to include devices that have...

05:51...maybe less resources or less functionality, lower-cost devices, right.

05:55So we can work with a device that has 256 megabytes of, you know, of RAM instead of requiring, let's say, 512.

06:03We can work with maybe flash storage, more flash storage, greater amounts of storage.

06:07There's usually an A-GPS or an accelerometer actually included as well.

06:11Optionally, you might see something like on a Mango device, you might see something, or a 75 device...

06:17...you might see something like a compass or a gyro.

06:19There's usually a camera involved.

06:21And so a lot of these devices are really sensors that can be used...

06:24...and you can discover and utilize within your application development experience...

06:29...to bring it all together to really package up really a single app that feels like a Metro-styled app, right.

06:36It's clean, crisp, effective, and responsive.

06:38So we're going to see a lot of this functionality in some of the apps that are going to be built today.

06:44Now there's really two apps, and I'm just going to do a brief I guess...actually, I'll let you guys introduce the app.

06:49I'll let the developers introduce the app, and so I'll move it over to Kylie, I believe, first.

06:55We're going to take a look at, really, a general audience app here at this point.

06:59I guess I'll just talk about this briefly to intro where we're coming from.

07:03Many cases, you're building an app that's not GIS-centric, right.

07:07You're not building an app where they want to see a map the first time they open up the app, right.

07:11So you're not a GIS analyst.

07:12You're not actually gathering information in the field, you're not out there...

07:15You know, you need to know where you are right now.

07:18A lot of times, with general audience apps, a bit more focused.

07:23So in this example, we're going to be talking about working with, let's say, a pizza company...

07:29...and we want to be able to provide the end user with the ability to discover how close...they want to make an order.

07:34They want to discover how close the location is that they're going to purchase the pizza is from.

07:38They don't necessarily need a map, right.

07:40But they're going to use logic that requires some spatial orientation.

07:44And so, there's...the general audience that's out there now, that, you know...

07:49...doesn't need to work with a map-centric application but can still leverage some of our controls and our functionality.

07:53So the idea here is that we want to be able to work within that general audience space...

07:56...but also handle situations where we're working with a true GIS, maybe it's a map-centric-based application.

08:03So we're going to take a look at both of those here.

08:04So I'm going to pass it over to Kylie to take a look at the general audience app.

08:09Alright. Thanks, Rex.

08:10So in this example, as Rex mentioned, what we're going to look at is an application if you wanted to, say, order a pizza.

08:18Let's go ahead and we'll open up the app, and the first thing a user...or a consumer wants to do when they order a pizza...

08:23...is set up what pizza they want to order.

08:25So we jump right on into that part of the workflow for them.

08:28We're not going to put them to a map, have them look at graphics first.

08:31If you're having a pizza delivered to your house, do you care the exact location of the branch?

08:36Do you want to see it on a map?

08:37No, not really.

08:39So let's go ahead and we set up a pizza.

08:41In this case, I put in some defaults so we can just go ahead and add that to our order.

08:45And we can add a second one as well.

08:46Let's make that one extra large, and let's give it some toppings.

08:49Let's go with pepperoni and sausage today.

08:53And, again, we can add that to our order.

08:56Now, in this case, I'm using a pivot, and we can see on the next part of the pivot here is how we place our order.

09:02So if we go ahead and swipe on over, we can choose with this order if we want it to be delivery or pickup.

09:08And we can choose what branch we want to use.

09:11And we can also review our order down at the bottom there. It has the foods that we've added.

09:16Now, if I want to do delivery, I probably want closest to my location, because it's going to be delivered, so just get...

09:22...I just want it to arrive as soon as possible.

09:24And I'm going to pick it up, there's a chance I'll want to do either a closest location or a favorite location...

09:31...say the one by a friend's house.

09:32So in this case, we've given the user some options.

09:35They can just use the closest location, which, as you can see here, the branch is already listed as the Palm Springs Airport branch...

09:42...because that's the closest to where we are right now.

09:45Or you can choose it from a map or from a drop-down.

09:47So let's look at the drop-down quickly.

09:49We see that there are four branches in this pizza parlor.

09:53And, you know what, I don't really want to look at that.

09:55I want to see it on the map.

09:57So we can, instead, decide...decide instead to pick it from the map, and you can see here that they can tap on a pizza joint...

10:03...and it will set it as their default.

10:06I'm going to go back to closest to my location, and if I had chosen a different branch than I'm closest to...

10:11...it would change right now what my branch is set to.

10:14So I'm ready to place my order.

10:16I've added some foods. I've chosen where. I've decided that I actually want to go pick this up.

10:21And I'm going to go ahead and place the order now.

10:24Still, unless they wanted to see a map to pick that branch, we haven't forced a map upon this user.

10:30They just want food.

10:32So we can fill out their information, and, again here, I've set some defaults just to save us from typing it all in.

10:39We can go ahead and place that order.

10:42At that time, we're switched to another part of the pivot.

10:45And in here, we're seeing the order, and, as you can see in red, the status of our pizza is changing.

10:50It was in the oven.

10:51Now it's being boxed, and it's actually ready for takeout.

10:56However, since this user is taking...doing takeout for this pizza, they do need to know where it is.

11:01They need the directions or the information about how to actually go pick up this pizza.

11:05And so from here, they can actually go ahead and look at those directions, and it'll generate the directions...

11:09...having total distances and time, information about all their turns, and for the user who likes to visualize the route they're going to take...

11:16...they can also view the map, and it will show the route that they should follow to get to their pizza.

11:26So that's a quick look at this app.

11:28Very consumer-based, as Rex mentioned.

11:30We're not looking at a map.

11:32We're not doing heavy GIS work.

11:34We're using location in a way that a consumer with a mobile device might need to use their location.

11:41Let's go ahead and look at some of the code for the API that's behind this application.

11:49So one of the first things that was done in the application was that it was able to make that drop-down of all the branches.

11:55Now to do that, I ran a query task, and I pointed it at, it's actually a hosted service that contains these four branches as points.

12:05I found all of the branches that are in that service, and then I just added those in...span that next part...

12:15...added each of those branches into a collection so that I could actually have the UI update based on what had been found.

12:22So if a new branch is added to the pizza company, they don't need to go release a new app.

12:27They update their hosted service that has all of their branches in it...

12:30...and the application would automatically then read in the new branch locations the next time it was used.

12:40Another task in the application that is using location behind the scenes is how it found the closest branch.

12:47Now to do that, again, we're using a task that is part of the API.

12:52We have the current location from the phone using the location service, and then we're going to use a closest facility task...

12:59...by saying our location as well as where all of the options of where we can get to...

13:04...it's able to find for us which of those branches is closest and return the information about that single closest branch.

13:15In this case, I know that my list of branches is going to match what's in my drop-down...

13:19...because I gathered them from that same service, and so I'm able to associate them back together and keep those in sync.

13:25So my selected branch is always a valid branch, and, at this time, it's now the closest branch.

13:37The other task that we're using from the API is finding directions.

13:42So in here, let me go up a little bit.

13:46Actually, that one got set up a little earlier in the code.

13:48So in here we set up a route task and, again, we just set some basic parameters like we do need the route back...

13:55...we want directions as well, what units to use, and if we're caring about time windows...

14:01...so there's a number of parameters that we can set up here.

14:04And then when the user actually clicks the button that says, Yes, give me directions, it just passes those...

14:14...it sets the parameters up that it...it already set most of them.

14:17It adds in where your start location is and where you're going to, and it solves a route between the two.

14:24Now one thing to mention really quick here, because I am kind of showing a lot of code really fast...

14:28...is that we are going to be providing all of the code for this demo after the session is over.

14:34They'll be available for download off one of the sites.

14:36So don't worry about all the details in the code. It will be available.

14:42So once we have solved the route, and we have a route passed back to us, we've set some parameters...

14:48...so that we can give the user back the distance and the time, as you saw at the top of that window.

14:54I've also taken each of the directions that returned, and in this case, I actually made its own type a direction class.

15:00So I was able to set the different pieces of the direction, about the time, the distance, and the actual text that goes with it.

15:06So that then in my UI, I was able to format that to best fit on a phone screen.

15:11The fitting is a little bit different than when you're working in a web API, because your real estate is a lot smaller.

15:16So that was one thing to keep in mind.

15:17We didn't want to just remember the list of directions but remember what each piece of direction was.

15:27So those are the key parts of the API that I was really using here.

15:30And let's take a look at the XAML as well.

15:34One thing that we did is made sure that we did some binding so that the UI isn't cluttered, right?

15:41As I mentioned, if you've said, I want this pizza delivered, you don't want directions.

15:45You don't want a map.

15:47So the option of viewing directions, viewing a map, those only appear if the person specified takeout.

15:52So that's one of the things to keep in mind on a phone, is that with limited real estate...

15:56...you really want to make the best use of that space that you do have.

16:01Another thing that I used in here from our API...let me scroll down a little bit...is called a child page.

16:10Now, when you saw the customer information up here, it kind of slid out nicely over the pivot.

16:16It didn't lose all my state in my pivot.

16:19It didn't...since it's a demo app, I didn't actually make full copies of all the data so that it would be tombstoned correctly...

16:26...and Eager's going to talk a bit more about those processes.

16:30But I just wanted it to work, and I didn't want to be switching pages.

16:33So we have this concept of a child page in the API, which basically is a little slider window...

16:38...that comes out on top without losing your context of where you're at in your application.

16:43I find it very helpful when I just want to present something really quickly or offer a choice without going away...

16:49...and doing something completely new.

16:56So those are the basics of this application.

16:58Again, I just want to reiterate that the focus is that it's not on a map.

17:03The API is more than just maps to display data.

17:06That's very important in a lot of applications. We'll use it.

17:09As you saw, we used it briefly even in this application.

17:12However, it doesn't have to be the focus.

17:14And so it's something to keep in mind when working on the phone, is that you can make these consumer-based apps...

17:19...and think about it how a user would want to use it as opposed to how a GIS analyst would approach the problem...

17:25...because sometimes you'll come up with a slightly different workflow and design.

17:30Alright. So turn it back over to Rex.

17:33Great. Thanks, Kylie. Good review there about a general audience app.

17:38Something to think about if...anyone here actually building a non-GIS-centric app, actually?

17:44Yeah. So something where you're just going to be plugging in some, I guess, some spatial capabilities at some point?

17:50Okay. Cool. Good deal.

17:54Great. So probably pretty commonplace for folks that just need to plug in...

17:57...and utilize some spatial operations or capabilities behind the scenes, but the next...so value across multiple platforms...

18:05...and multiple...for multiple...in multiple capacities.

18:10The next app that we're going to look at is more of a GIS-centric app, we're going to cover a lot of functionality...

18:19...in both the Windows Phone platform as well as the API, and it looks like...you guys good to go?

18:26Alright. So Eager's going to take it from here.

18:29I am testing the AML, actually.

18:32It's...

18:34Is it showing up?

18:35Shutting down by itself, so let's see.

18:43While we are waiting, I can switch on...

18:52So this is the second demo.

18:55It's about...Kylie's demo is about, like, a consumer-based app where you consume data.

19:02Like you grab it from line and then you run some GIS analysis to determine your best route, you know, where you are at.

19:10This app also does that because most of the time you need to grab some data first, right, to show your user...

19:17...and this one is on a service that do...recording some noise with your phone.

19:25So let's assume there are some microphone calibration experts that tell us, Hey, we know how the phone micro...

19:35...we can use the phone microphone to collect some sound data, and then we just say...

19:39...Okay, put it on the map and then let people, like, look at it to determine where your converse zone is...

19:47...or if you like party zone, right, you just...some, it's like an app; that way you can look at data and also collect data.

19:57So this is, lack of better name, is called noise crowdsourcing app.

20:06So let me try to see if it comes back to life.

20:11Is it OK or it's bad?

20:18You can see it? Alright.

20:22So what it does, the first screen, what it shows is pulled from a feature service similar to the pizza app we have.

20:29We have a hosted feature service on ArcGIS Online where it will show you the latest sound data collected so far...

20:38...and then what you can do is select one of them and then what it shows you like a general location of where it is...

20:47...the sound level is peak at 70, and then the average is 66, and it's...notice I use a component one control on it...

20:58...this little sound gauging control, and...let me show you another point location.

21:06This is a pivot control, showing the data of the specific point, and what you can also do is...

21:13...what it's doing now is just trying to find the zone that the noise level is lower than the selected point you have.

21:21So that's why you see this shape here.

21:25If you go tap on that, and see, because there are other data points around it, and they are louder than this selected point.

21:35So this is, little bit, an analysis map showing, Hey, you know, this is the area that is kind of like the zone of this sound level.

21:47So we did some advanced buffering and query to determine this area I'm showing on the map.

21:54And one thing you might notice, that it is the pivot, and generally you don't want to put a map on the pivot...

22:00...because it will conflict with the gesture.

22:03So I put a Zoom In and Zoom Out button here if you want to zoom in and zoom out, but if you really want to interact with the map...

22:13...by design is you tap on it and you will see the pivot kind of disappears, so now you're free to like use a gesture...

22:21...and then click the Back...tap the Back button and then we're back to the pivot mode.

22:27So it's one thing like pivot is...pivot and panorama is a very common natural design and it...you can, you know, make it work.

22:37So, but you just need to put some thinking about it, the interaction with it.

22:44So that's the query and analysis part of this app, and what I want to show you now is, we want to collect some data...

22:54...and so we tap on this Recording button, and if I press and hold the tap and hold button, it will start using the microphone...

23:04...and detect noise levels, sound level bites from the microphone.

23:09The algorithm is pretty arbitrary. It's not decibel. It's not, but it just shows you how it's done.

23:15We're using the microphone as the sensor.

23:17And then once I release it, it will say, Hey, you collected some sound data.

23:21We do the analysis and say, Hey, the peak level is 73, the average is 53; do you want to upload the data now?

23:28And I can say, OK, and what it does is...what it does now is starting the GPS location, and once I get the GPS location...

23:36...I would then push the data up to the feature service.

23:39So this is done.

23:41And if I go back to this list and hit Refresh...

23:47...you will see this data get submitted on the feature service and get pulled down onto your client.

23:58So this is pretty much basic and then we add some...it will be hard to see on the emulator.

24:05Something I want to show later in the code is, on the Windows Phone, there is something called reactive extension...

24:12...which is pretty cool for a programmer, and what it does here, I'm just collecting accelerometer data...

24:21...and when I do the shake, it will start...do the autorefresh itself.

24:26So it detects a shake and then invokes a command, and the command here is a refresh.

24:32Let me actually try to do this so that you can see it better.

24:44Waiting isn't fun...a GPS location.

24:48So on top is the progress indicator where you can data bind to some property, and I'm still locating GPS location...

24:58...so don't know what's happening.

25:05Yes. So that's pretty much what this app does.

25:09So let's dive into some code quickly and see how it's done.

25:22So in the first part of the demo, I'm just showing the same similar query as Kylie showed on her app.

25:28One thing new at the 3.0 - we're using the 3.0 prerelease API - is in the query, you can specify an order by fields.

25:36So that's why you will see I'm order by the date/time.

25:39There's a DateTime field in every record so then I don't have to do the sorting myself.

25:44You can...the query task, you can specify it.

25:49So pretty much pretty basic code, asynchronous programming, query task, run the task.

25:56Whenever it completes, then we populate the items.

26:02So that's query, and I'm sure you guys seen a lot of it, so let's dive into another thing about the secure...about the hosted service.

26:12One thing you can do with a service, a hosted service, you can secure it on ArcGIS Online, and new at...say new at 3.0...

26:23...the API 3.0 API, we provide the identity manager for you to easily set credential to access your service.

26:35So the way to do it is assign a challenge method, and the challenge method has this delegate signature to it...

26:44...and what it does, it's pretty simple.

26:47You can call...you're going to steal my user name and password...generate credential with your user name and password...

26:53...and once it's successful, it will get a callback here and then you just say, Let the identity manager know...

26:59...Hey, use this credential for this URL.

27:03So that's pretty straightforward.

27:06Of course, in a more event, or in a real app, you don't hard code the user name and password.

27:14You will have to store it in your app or, you know, pop up a dialog.

27:18So there will be, you know, little more work to be done to provide a user experience, but this code just shows you...

27:25...this is new and you can easily use it.

27:30And one thing I mention is some of the token generation requires you to set a referrer header.

27:38So the identity manager provides a mechanism to do that.

27:44And a little trick on Windows Phone is, on every web request, the phone will actually stay attached to the referrer header...

27:56...which has this format.

27:58It will be files:Applications/Install and the product ID you specify in your app manifest right there.

28:12And don't try to hard code this if you're going to submit this app to the Marketplace...

28:17...because when the Marketplace publishes your app, it will change your ID.

28:23So this is a little code that helps you to figure out, read the XML file and then pick out the product ID for you.

28:34So you will have this code where we're going to...so you can look at it in detail how it's implemented.

28:42So that covers identity manager where you can access secure services.

28:50I should do that from the screen.

29:00So next I want to show...there were a couple times Kylie and Rex mentioned about the life cycle of the Windows Phone app...

29:07...which is, if you come from the Silverlight development or other OSs, which is something I think it's new and different...

29:18...that you have to be aware of.

29:23So to track those events...so an app when you first start it from the Start screen, the launching event will be fired...

29:35...but the recommendation is, don't do too much in it, because that's why, otherwise, your app will take a while to start...

29:44...and it's not responsive.

29:47So there are different strategies you can use, like we'll have to wait till maybe the first map page, I mean, first page to be loaded...

29:53...then you start doing...grabbing your data. So that's one tip.

30:03And when the app closes, that means when the user taps the Back button...

30:11...when you are on the first page of your app, then the app is closed and exit.

30:17If you're using the Silverlight flavor of Windows Phone development, you cannot call, there's no...

30:25...you cannot call Exit to exit your app at any time.

30:28So keep that in mind.

30:30The only way that actually the app exits is when the user taps the Back button on the first page of your app.

30:39But there's another trick if you throw in unhandled exception, the app will close, but I don't think that is recommended.

30:47So, but in a simpler world, that would be perfect.

30:51Launching and exit, great.

30:53But on a phone is multitasking, you know. You may get a phone call or you might be in the middle of something...

30:59...you want to go to...start sending an e-mail or something.

31:04So what it does is, before Mango, all the apps will get tombstoned.

31:11What tombstone does basically, actually what it means is your app, the process is killed, it's terminated.

31:20But when the user comes back to your app through the Back button, the back stacking, the guidance is...

31:27...you have to make it feel like actually the user hasn't left the app.

31:34So there are two other events to check, to track.

31:38One is Deactivated.

31:39So whenever the user taps the Start, Windows Start screen, or get a phone call, or, you know, they sort of decide to use the camera...

31:47...your app got deactivated, and that's where you need to store transient data and also any application cross section data too...

31:59...because your app might never...your app might get relaunched again from the home screen...

32:05...and then the launching process will restart.

32:08So Deactivated is your last call to cache data when the user leaves the app by using...through tombstoning...

32:21...or when they switch over to another app.

32:25So once the app gets deactivated and the user comes back to the app, before Mango, all the apps get tombstoned...

32:34...and then restore from tombstone, like what I said. It's because the app...the process got killed...

32:40...and then you have to reestablish all...rehydrate all the data yourself.

32:46Usually you will store your data into the application state object...

32:52...but after Mango, there's a state...they have a new function, an IT feature called fast app switching.

32:58So what it does is, when the user taps the Home button, your app got pushed to the background.

33:07So it's still running, but it's not in the foreground.

33:11So all your memory and state is preserved as if you haven't left the app.

33:16So then when a user comes back to your app, you don't need to do much, like...

33:21...because basically all the memory and the state is restored for you.

33:25But, in case, when it actually got tombstoned, then you need to like load the data again.

33:31And there's a flag for you to check whether or not the app gets actually tombstoned or gets dormant...

33:38...which is not killed but it's just pushed into the background.

33:44So these are the events to look for and to...for the life...to maintain the life cycle of your application.

33:58And one thing we learned during writing the ArcGIS app is, you shouldn't try to store large data on the application state.

34:12Your app will get...when your app gets dormant, you won't see any message...

34:18...but actually there's some unhandled exception gets thrown...

34:21...but you won't see it even though you put a message box in the UnhandledException event...

34:27...and then the mysterious part for a user is when you come back to the app, [unintelligible] dormant...

34:33...you see Resuming... and then like a second later and then your app just closes without any warning.

34:39So we were trying to figure out like, what's happening, what's going on?

34:42We don't...we want the debug information, and then we found out what happened is...

34:52...in the Windows Phone ArcGIS app, we are storing some attachments, a lot of photos...

34:57...and then we are storing in the state, and if you run this code on deactivation, basically we throw an exception...

35:07...but this exception got silent because your app got dormant, and then when you come back, you're like...

35:13...I don't know what we did. What's going on?

35:15Then we did some...a bunch of things, look at different things, and then we finally figure out actually...

35:19...because the exception is pretty ambiguous, is a calm exception, which generally for Windows Phone development...

35:28...you don't expect to see calm exceptions, and you don't want to see calm exception because it's native code.

35:35So one trick, what we find out is, it's always a good idea in your UnhandledException handler...

35:43...that we...you just cache and serialize any exception thrown, because the message box when the app goes dormant...

35:52...message box won't show, so you won't see it.

35:55So it was a good idea that, you know, cache it and maybe put a debugger if statement there, if the debugger is attached then...

36:04...or in the debugging configuration just for you to troubleshoot, you know, during your development cycle.

36:09So track that and then at...you can later on sometime when the app relaunches again show, hey, there's exception thrown last time.

36:21At least you can see some information.

36:24Another trick you don't have to show in the app is I think you can use the isolated storage explorer...

36:28...so you can just grab this file and then just look at it.

36:32So it's a little...application life cycle is tricky, depending on your app, and you will find surprises like this...

36:41...and this is one thing we did to find out what's happening.

36:49Okay, so next.

36:55So in the app, you will see we collect some sound data using the microphone, and then once we collected the buffer...

37:06...we will turn on the GPS and collect some...collect your location and then submit it to the feature service.

37:15So one thing we learned from developing the ArcGIS app, same time, is there is a precision setting on your GeoCoordinateWatcher...

37:30...so generally when you do tracking, you want to use high.

37:33That will consume more battery power.

37:35It will take longer to start up.

37:40Keep that in mind.

37:41And also, it will be nice to set a movement threshold, and here I set it to 20 meters.

37:47I don't care about high precision, and if you want really high precision, we set it to 5 in the app...

37:55...but I don't think the phone can get any better, so we set it to 5.

37:58So what it does is, only when you move 5 meters from...well, 20 meters in this case, from your last location...

38:06...then you will get the PositionChanged event.

38:08So you won't get constant firing.

38:10If you don't set this movement threshold up, you will get an event fire every second.

38:17So one thing to keep in mind, you know, is initialize GPS parameters appropriately for your app.

38:23And another scenario, like, if you want just to use a general search application to find your general vicinity...

38:31...you don't need to use the high accuracy.

38:33You should use the default accuracy so then you consume less battery power and it's faster.

38:39Another thing we learned is try to have only one instance of GeoCoordinateWatcher in your app...

38:45...because if you have multiple ones and they have different parameters and settings, it kind of conflict each other...

38:55And one last thing is, it's also...always a good idea to check the time stamp of your geoposition returned by the PositionChanged event.

39:08What happens, we found if you have turned on your GPS earlier on in a different location...

39:15...and then you move to your current location and then you turn on the GPS again, sometimes what it does...

39:25...it will give you actually the last position right away, say, Hey, this is the position...

39:30...but, which...I call it stale location, because it might be accurate, depends on how far you've moved from your last location...

39:37...but if you check the time stamp, try to weed out location that is not current, is also a good practice for...

39:48...especially for GIS workflow, mostly you want, you know, you don't want a stale location. It's wrong.

39:55One last thing we learned about while programming the GPS layer is, you guys should know there's the emulator.

40:03I think Kylie kind of showed the emulator, and it's good...

40:11...to simulate location, but it doesn't have any accuracy set to each point.

40:18And also, if you want to task between high accuracy and default accuracy as I mentioned, there's no facility here to say...

40:27...Hey...to detect that scenario.

40:32Because one thing we found while developing the app is, well, somehow the setting got...didn't get set to high...

40:39...and then we were walking around and say, Why the GPS layer is way off?

40:43We're like, what's happening?

40:45And then later...and then if I test it on the emulator, of course, there's no different...

40:49...because we'll report the location where you click, but when you're in the field, if you don't have the accuracy set to high...

40:58...your location would be maybe based on your cell tower, so it will be off and then you try and figure out, Hey, what's going on?

41:07So in the field it doesn't work and, you know, when I'm debugging sitting in the office, it works fine...

41:16...and so, it's one thing to keep in mind; it's like, keep track of your GPS parameter settings on the phone.

41:31So let's...and if you're familiar with...and one more thing, after...right after we got the GPS location...

41:39...we just submit the graphic to the feature service, and I'm not going over the detail on how it's done...

41:47...because it's basic API call and nothing fancy, nothing special.

41:51We just create a graphic and call SaveEdits and add to the graphic collection to the layer.

42:07So let's do something fun.

42:13I'm going to show you one more thing before that.

42:17New, I think 2.4...before 2.4 when you have your own graphics layer and when you add graphics...

42:24...you have to make sure the graphic is the same spatial reference as all the other graphics.

42:30At 2.3, I believe, 2.4, 2.3, there's a new property in your graphics layer where you can specify the projection service...

42:42...and what it does, it, the class, you have to implement it yourself as...you have to implement IProjectionService.

42:51What it does is it will...when you add a graphic that's in a different spatial reference as the graphics layer...

42:58...it will call your projection service and say, Hey, you have to reproject it for display of the layer.

43:05So then you don't have to change your...if you don't have to bind to your graphic stores and you want to keep the original data...

43:12...this is a good way that, you know, you don't change your model or your model data, but for the display, it will still work.

43:22And then one note that if your...I think at 2.3, if you have geographic and web Mercator coordinate system thing...

43:32...it will automatically reproject it for you so that you don't have to do any work.

43:35So if you're sure your layer and your data is between, you know, is either on geographic WGS84...

43:44...or the web Mercator coordinate system, then you don't need to worry about using...implementing your own projection service.

43:53But this guy, the source code will be available, what it does is, it will try and use the client-side projection, if possible...

44:05...otherwise, we have to send it to the server using the geometry service.

44:15So one thing I'm trying to show on the AML is using the accelerometer to detect a shake...

44:24...and then once, you know, finish shaking, I will do the automatic update.

44:30So I am using something that you don't have to download separately.

44:35It's already available on the phone.

44:38It's called reactive extension, so the name space is like Microsoft.Phone.Reactive...

44:45...and this, what it does is accelerometer, you can set it up and then just listening to the event...

44:52...and if you do some WHERE clause and say, Oh, if the accelerometer reading exceeds this value...

45:04...then I'm going to report it to you, say, Hey, I'm going to push the message saying...

45:08...Hey, something happened. So then if you subscribe to this observable collection...

45:19...whenever there's a value generated based on this event, you will receive a message and then to handle it...

45:27...you can just call subscribe to this event, I mean, subscribe to this...yeah, you can call observation and then do whatever you want.

45:37So that's how I implement it.

45:40So reactive extension is pretty fun on the phone.

45:44So this is just one example how it's done, and it's pretty short and sweet.

45:51So one last thing actually I want to show you about is on the phone, there's something called push notification...

46:03...and let me set up real quick on...so what it does is, for example, if I have...

46:13...someone else has a phone and then I collect some data.

46:16I want the update to be automatic.

46:18I don't want to do it myself manually by pushing a button.

46:23So what you do is, you set up a push notification service and then your phone has to subscribe to it...

46:32...and then you open the channel to the push notification service, so instead of you constantly pulling from the web service...

46:38...where it does, Microsoft provides this push notification server where you have a web service talk to it and then say...

46:44...Hey, I have something has changed then push it over to the phone.

46:49So that's basically a similar, I think, iOS and even Android, yeah...

46:52...on all smartphone platforms they have some kind of push notification system here.

46:58And I think we have time may just to show how it works.

47:06Let me do a little trick here.

47:14Only thing I need to change is, instead of adding data through the client code, I'm going to add the data through this cloud service...

47:25...a WCCF service, which knows how to talk to the...do the push notification.

47:33And let me...so what I'm going to show you that I have the emulator up and then I have this phone up which is going to collect the data...

47:48...so let me deploy this to the phone as well.

48:09So what I am going to do is start the emulator here and what I'm going to do, you won't see on the screen...

48:23...is I'm going to collect a sound data, and I'm going to make it really loud this time because you guys are really quiet.

48:30So [bells ringing]. It doesn't do that [bells ringing].

48:36Okay. So I collect a really loud data point, and it shows up.

48:46So that's how push notification works, and I think this is one thing we haven't explored a lot in ArcGIS app, but it's...

48:53Anargyros, actually he did a lot of the backbone for this demo, and I think it's something...I think it's really useful.

49:01I think a lot of people when they download the app, they care about there's some push notification enabled.

49:05So I want to be notified when something happens, right?

49:09So we got the code for you.

49:12I think we are running out of time but, so to see how it's done. So that's pretty much what I have.

49:26Does this actually show the...it's alright if it doesn't, yeah. Okay.

49:32Alright, so there are no additional slides actually on that one.

49:34So thanks, Eager, actually great demo.

49:39She's showcasing a lot of different functionality, obviously touching on a variety of the different...

49:43...the new functionality that's going into ArcGIS Server 10.1 as well as a lot of the platform-specific functionality...

49:48...looking at some Metro design, looking at some execution model capabilities, some...working with some sensors.

49:53Obviously another capability is...she mentioned Anargyros.

49:56Anargyros is another rock star developer, actually, on the Windows Phone team as well.

50:03He's handing out surveys over there. Good stuff.

50:08It's personal service here. Actually, it's small enough so we get personal service.

50:13At this stage, what I'd like to do is open up for questions.

Copyright 2013 Esri
Auto Scroll (on)Enable or disable the automatic scrolling of the transcript text when the video is playing. You can save this option if you login

Building Applications with ArcGIS Runtime SDK for Windows Phone—Part II

Kylie Donia, Eager Ip, and Rex Hansen share best practices for implementing data collection in your applications. 

  • Recorded: Mar 28th, 2012
  • Runtime: 50:17
  • Views: 744
  • Published: Apr 24th, 2012
  • Night Mode (Off)Automatically dim the web site while the video is playing. A few seconds after you start watching the video and stop moving your mouse, your screen will dim. You can auto save this option if you login.
  • HTML5 Video (Off) Play videos using HTML5 Video instead of flash. A modern web browser is required to view videos using HTML5.
Download VideoDownload this video to your computer.
<Embed>Customize the colors and use the HTML code to include this video on your own website
480x270
720x405
960x540
Custom
Width:
Height:
Start From:
Player Color:

Right-click on these links to download and save this video.

Comments 

Be the first to post a comment
To post a comment, you'll need to login.
If you don't have an Esri Global Login ID, please register here.