Unlimited Possibilities through Code
OK, I have been writing Windows Phone apps for a while now. I have a few baseball apps that have been pretty popular. Recently I have been focusing on up coming NFL Football season, and of course I did the Jacksonville Jaguars first. Almost immediately after showing my first app to some friends here at Microsoft they wanted their favorite teams to have an app. Living in Seattle I had to do the Seahawks, and then the order has pretty much been from the Roosevelts Most Popular Football Teams according to the Internet.
Each app is unique in terms of graphics (and YES I drew all of the graphics for these apps), and the feeds that are included for the team. But there are of course many common features across all of the apps. Scroll to the bottom of the article for a complete list of those teams I have finished to date, and links to the Windows Phone Marketplace.
Each app has the same basic features.
I just ran into this on one of my Windows Phone projects and thought I would share a little insight into why it happened, and how I fixed it.
This is a project that I have had existing for quite a while, but I copied it all to a new folder and renamed the assemblies. That is when things went bad.
I remembered that you need to change the namespaces in all the pages (even the XAML), and that you have to remember to go to the project properties and set a new Startup Object.
Make sure everything is building at this point, but even if it is take a little extra time and right click the project and select the Clean option. It will remove ALL the files in the obj and bin folders. This was the actual problem in my case. There was an OBJ file that had not been correctly rebuilt. After running clean, the build then went smooth and the PhoneApplicationService object was happy.
I built an app just for myself recently and decided to share it. Those are always the best apps to build, ones that have some personal meaning or use for yourself. And this one is no exception.
You can download this app from the Windows Phone Marketplace – Mariners News.
I attended a class where we had just two hours to make a start to finish app. I actually didn’t intend to build this app, and had no idea we were going to do this at the event. I am actually quite glad we did, as it showed me I could do a lot more in a phone app in just a few hours than I would have thought possible.
The previous topic of the class had been using the Bing API to make requests for data and news stories. Just that morning I had been looking for a way to get news about the Seattle Mariners. There was one app in the marketplace, but the UI was terrible and slow. Viola, an idea is born.
Ok, I did make the app in under two hours, but I spent an additional hour and fifteen minutes at home that night making the icons, testing for the marketplace certification, putting in the Ad control, and preparing the submission.
Oops, I grabbed the official MLB logo when I built the icons. I wasn’t really thinking about it the night I submitted, I just went to MLB.com and grabbed the official logo. Almost the next day the Windows Phone
Developer Blog came out with an article about avoiding trademark trouble
I should have known better. Really, I have done this type of thing before.
So I sat down that evening using Expression Design and built a new logo. It is close enough for people to recognize it as the logo, but it is my version of it. No trademark or copyright issues!
Quick, simple and clean. I like it.
And then I began the long wait for certification (which you can’t cancel or abort). So I thought what else would I want to change? I am going to need to submit an update anyway, better make it worth it.
At this point I thought more about the navigation experience.
I didn’t like the display of the news articles and with about two evenings of playing I came up with the following design that I am much happier about.
Notice the stories are cut at two lines, if you click you get the complete RSS or news story as it was returned from Bing. Then if you want you can launch out to IE from that more detailed page.
I got rid of the images for the source (too much space), and just added an tagline, then about how long ago it was posted. Seeing the date and time doesn’t really do much for you, but seeing about four hours ago seems to give it a fresher feeling.
This is where I started thinking about what else I would do with a Windows Phone. I want to check for tickets, directions to SafeCo, tweet about the game, etc.
Most of these are pretty simple stuff, but add a lot of usage to the app.
The call for tickets actually goes call the correct Ticketmaster line for you. I don’t know of any other sports app that does that, and it is a uniquely mobile experience. You wouldn’t want that on your desktop, but on my phone it makes perfect sense.
Directions to SafeCo Field. Another unique experience for mobile phones. I may be lost downtown while going to a game (it happens). Quick couple of taps and I am getting directions.
Get on demand updates of news and scores through SMS is a feature that ESPN offers. But I can never remember the number, so I built it in. Now with a quick tap I get the latest box scores or news.
Share the #mariners spirit is something I want to add more to over time. The ability to profess the love for your team, taunt the opponent, or just complain about the call are all social elements to the game today. I would like to build in more Twitter integration to let users interact about the game while watching a game.
I actually finished this version of the app just a few hours after the version 1 was approved for the store. But even after approval it still takes 24-48 hours before an app goes live on the site.
I was very happy to be able to submit a quality update almost immediately. Now I just have to wait for it to be approved!
This was a really fun project, and one that I am sure I will continue to update as I find more things I want in it myself.
I am already thinking about a way to use a live tile to show me the next team opponent and the time of the that game. Too bad you can’t add calendar items on WP7, maybe a push notification that the game is getting ready to start? Hmm. I can listen using MLB At Bat to every game, so that might work. Ahh the possibilities.
Enjoy your projects, and hopefully from baseball this year too!
I did an after hours XAPFest talk a while back on Managing Data on Windows Phone 7 that is now published on the Microsoft Research site! I am actually sort of proud that this session was the #2 most attended talk at XAPFest!
Microsoft Research – Managing Data on Windows Phone 7
I did a follow up blog post entitled Minimal virtualized data list for WP7 showing how to implement the code I spoke about in the video. The source for that is available on Bitbucket.
I got an email from someone today asking about how to take a resource from their XAP (which is read only), and put it in a location where they can update the file.
I highly recommend this approach for getting an initial data load for your application. Give the application a base of files to work with rather than requiring an initial round trip to a server for those files. It is fine to need to update them almost immediately. Think about the scenario where the user has no network access (a first run of the app this is really vital). Does the user get an error that no data is available, or do they get a nice default experience? Even if you just put in data that says “no data here yet”, that is better than a blank screen to the user.
I put this in a utilities class as a static method since it doesn’t really need any state. One thing to ensure you do is put a using() block around the objects that are disposable. This ensures they are cleaned up and released as quickly as possible. I think this is a common reason why people think they need to GC.Collect, they are not cleaning up memory.
public class FileUtilities
/// Given a resource name, create a file in the isolated storage.
/// Resources are read only, but copying them to the isolated store means you can edit them.
/// Useful for including a starter file in your XAP, and then copying it out to storage
/// for editing it at runtime.
/// <param name="resourceName">The name of the resource</param>
/// <param name="fileName">Optional param for the name of the file, /// by default uses the same name as the resource</param>
public static void CreateFileFromResource(string resourceName, string fileName = null)
// Find the resource and get the stream
// Note the using() block to ensure this gets cleaned up when we are done
using (var resourceStream = Application.GetResourceStream( new Uri(resourceName, UriKind.Relative)).Stream)
// Get the location where we can write files
using (var userStorage = IsolatedStorageFile.GetUserStoreForApplication())
// Use the filename (if given) or the resource name
using (var newFile = userStorage.CreateFile(fileName ?? resourceName))
byte byteBuffer = new byte;
int bytesRead = -1;
while ((bytesRead = resourceStream.Read( byteBuffer, 0, byteBuffer.Length)) > 0)
newFile.Write(byteBuffer, 0, bytesRead);
Please forgive the formatting above, trying to make it fit on a smaller size screen.
I attended a great XAPFest meeting last night about TouchDevelop. This is an app you can download today for your Windows Phone 7 from the Web Marketplace.
Many of us were introduced to programming because we had computers at home (and usually lots of free time). Most machines had built in BASIC or some other language, and there were lots of magazines and books with code you could type in to make your machine do what you wanted.
Today most machines do not have a built in language, or tutorials on how to use the built in tools like Powershell to write programs. Even then the tools and learning curve is very steep. Learning to do something like post an image to Facebook means having to learn a LOT of different technologies.
TouchDevelop is a very easy to use programming tool that lets users write applications directly on the phone. No need to sync to a PC, or learn C# or even know the SDK. All of the features of the phone are exposed through built in objects in the tool. The user doesn’t have to know the difference between a JPG and a PNG. They just say Image.
Pick a Park is an application I wrote for my kids on a different phone platform. We used it to help us decide what park we wanted to visit while driving to Walt Disney World. We originally had a Disney pin that we could spin to decide, but it would always be forgotten at home. Since we lived about an hour away from the parks it was pretty easy for us to go, but there was always the debate about which park to visit.
The application is a very simple way to choose from two or more of the Walt Disney World theme parks and get a random choice of which one you should visit.
Pick A Park is in the Windows Phone Marketplace
This version is for Windows Phone 7. Since I work at Microsoft I got a free phone right when they first launched. This app was my initial way to help learn the programming model. I wrote this over Thanksgiving weekend 2010, but I was so embarrassed by the app that I never released it until summer 2011.
The reason I finally released it was a XapFest event I attended where another internal Microsoft employee said that he felt you should always release the app while you are still a little embarrassed, it will keep you humble and motivate you to improve it.
To date there have been hundreds of downloads for what I was pretty embarrassed about at the time. I get a few hate mail, but I get a lot of people just asking for advice on what park they should visit when they only have 1 days in Orlando after a conference. Overall it has been a great experience.
I have been toying with the app more and more as Windows Phone Mango has progressed through beta. I wanted to initially include two modes, one for picking the park, but another for just exploring which park you might want to visit. But I couldn’t figure out how to do the data filtration because there was no database on the phone. Now with Mango there is an embedded database (SQL CE), so I wanted to revisit the problem. First a little about the current version.
I am sure that most people who follow Windows Phone 7 already know all about Mango. But if you are just sort of casually following what Microsoft is doing around the new phone platform you will have missed a lot of what is in this video. Joe Belfiore (Corporate Vice President) does a demo of some of the highlights for Mango.
Go watch it directly on YouTube, it is a good video.
©2010-2012 Jason Short. All Rights Reserved. The opinions expressed herein are my own and do not represent my employer’s views in any way.