Archives for May 2011

Windows Phone 7 App: A Quick Tweet

Screen02Screen01So I have another application in the Windows Phone Marketplace publish today. It’s a nice little application with great functionality. Saving you 10’s of seconds at a time 🙂

If you use twitter from a Mobile Application, you know it’s sometimes slow to start. When these applications start, they typically try to download you latest DM’s, Timelines, Icons’, and who knows whatever else.

Enter “A Quick Tweet”

The purpose for this application is simple. Post to twitter. It has no network traffic, so the application starts almost instantly. In less than 1/2 second on my Samsung Focus.

When you start the application for the first time, you have to press the settings icon, to open the Twitter OAuth page, and authorize the application to post on your behalf. Once you’ve done this, the application returns to the Twitter Input screen.

That’s it, that’s the application. If you try it, you’ll be disappointed by the speed of the competing applications. now in fairness, if I was writing a full fledges Twitter Mobile Client, it might be just as slow. But in a lot of cases, I want to post and go, so this is perfect.

In a future update, you’ll see support for multiple accounts, and support for the Picture Hub, where you’ll be able to attach photos to your Tweet. And maybe I’ll add GPS coordinates. Who knows.

One thing I do know is …. writing applications for Windows Phone 7 is a great time!

#9 Windows 7 Keyboard Trick to Move Application Windows

There is a Keyboard trick that is very common with [WIN]+[Arrow] that will move windows around your desktop, and dock them side to side. Here is what the four arrows do …

  • [Win]+[Left Arrow] will Dock the active window to the left of the current screen
  • [Win]+[Right Arrow] will Dock the active window to the right of the current screen
  • [Win]+[Up Arrow] will Maximize the active window
  • [Win]+[Down Arrow] will Restore from the Maximized Position, or Minimize as an active window

So as I mentioned, these have been demo’d so much, that most power users know them.

Here is the trick I’m posting. It deals with Multiple monitor support. You can use the above tricks to move a window from one monitor to the next, by simply repeating the Left and Right sequences. BUT … did you know there is a single keyboard shortcut to move a window to another monitor? Move this windows from Monitor A, to the same position, but on monitor B, (or vice versa) by pressing …

  • [Win]+[Shift]+[Right|Left Arrow] Move Active Windows to the Next Monitor (Right or Left)

If you only have two monitors, then using the left or the right arrows will do the same thing, because the monitors cycle. But if you have three or four monitors, you can use this trick to cycle monitors left and right?

Have a great Day 🙂

@scottcate (on twitter)

I’ve been accepted as a Microsoft Regional Director

I’m happy to have accepted the prestigious Microsoft Regional Director award in February, 2011.

The Regional Director program is an award that is given to outstanding community members, who support the Microsoft Stack. You may have heard of the MVP program? The Microsoft Most Valuable Professional’s are awarded based on a specific technology. I’ve been an ASP.net MVP since 2003, and continue that award through the time of this posting in 2011. The Regional Director award is given to members of the community that have tremendous reach across multiple technologies. It’s important to understand, I don’t work for Microsoft as an employee, and that this is simply an award that I have been given.

To put the award into perspective, there are (I’m guessing here) around 6000 Elite Technology MVP’s worldwide. There are only (again I’m guessing) around 250 regional directors from around the globe.

I’m honored to become a part of such a strategic and influential group of people. Regional Directors have been around for many many years, and now I’m the new kid on the block. While I do know many (err most) of the Regional Directors, I’m excited to meet and build a relationship with the others on the team that I don’t already know. Especially the international members.

Thank you to everyone that had a hand in making this happen. I won’t let you down.

@scottcate (on twitter)

Windows Phone 7 App Rejected–Crashes when Offline

I wrote an application for the Windows Phone Marketplace, and it was rejected. I use the internal WebBrowser control, and I never tested it without the internet connection. Here is the hard part – the Emulator is always connected, there isn’t a way to turn it’s internet connection off (that I know of).

So I tested it on my phone, in airplane mode, and sure enough, it crashes.

Here is some code from MSDN that I was able to use to do some checking if there was internet access.

Windows Phone: Working with MediaLibrary.GetPictureFromToken

I struggled with this for a while, so I thought I would throw up a post, to help out people running into this is in the future.

From MSDN: Here is the code sample you’re lead to, to use the Extras item in the photo hub.

Add the Extras.xml file …

   1: <?xml version=1.0 encoding=utf-8 ?>

   2: <Extras>

   3:   <PhotosExtrasApplication>

   4:     <Enabled>true</Enabled>

   5:   </PhotosExtrasApplication>

   6: </Extras>

and then use the OnNavigatedTo method.

   1: protected override void OnNavigatedTo(NavigationEventArgs e)

   2: {

   3:     //Gets a dictionary of query string keys and values

   4:     IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;

   5:  

   6:  

   7:     //This code ensures that there is at least one key in the query string, and check if the "token" key is present.

   8:     if (queryStrings.ContainsKey("token"))

   9:     {

  10:         

  11:         //This code retrieves the picture from the local Zune Media Database using the token passed to the application.

  12:         MediaLibrary library = new MediaLibrary();

  13:         Picture picture = library.GetPictureFromToken(queryStrings["token"]);

  14:  

  15:         //Creates WriteableBitmap object and adds to the Image control Source property.

  16:         BitmapImage bitmap = new BitmapImage();

  17:         bitmap.SetSource(picture.GetImage());

  18:         WriteableBitmap picLibraryImage = new WriteableBitmap(bitmap);

  19:         retrievePic.Source = picLibraryImage;

  20:     }

  21: }

The problem is …. well there are a couple problems.

When you run this code (or when I ran it), I was getting an “An Unknown Exception has Occurred” error. Great – thanks for that. Inner Exception was null, so no help there. The error was happening on line 13, where the photo was trying to be fetched.

First. You can’t debug this. Because you can’t see pictures on your phone, while it’s connected to Zune, which it must be to have the debugger attached. So you unplug your phone, and then you can see your pictures, and the Extras in the application bar, but … if it fails you don’t know why.

Here are the steps I took, and then finally solved the problem.

First, I wrote the token (which is a GUID) to a text box. Once I knew the GUID, I could run the code outside of OnNavigatedTo, and then I noticed in the Quick Watch window that Library was instantiated, but had no photos, saved photos, genres, nothing. Everything was zero count. Then it hit me. The App Cap’s weren’t turned on.

So the answer is …..

Make sure you have the ID_CAP_MEDIALIB turned on in your WMAppManifest.xml file, like line 6 below.

   1: <Capabilities>

   2:   <Capability Name="ID_CAP_LOCATION"/>

   3:   <Capability Name="ID_CAP_NETWORKING"/>

   4:   <Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>

   5:   <Capability Name="ID_CAP_GAMERSERVICES"/>

   6:   <Capability Name="ID_CAP_MEDIALIB"/>

   7: </Capabilities>