Category Archives: Windows Phone 7

Upgrading your Windows Phone 7 to Mango RC

In late July, Microsoft announced availability of a new build of Mango, build 7712 – also commonly known as the RC Build.  Given that we are close to RTM, yet it may still take carriers some time before deploying Mango to your device, you might be itching to try out the new bits.  If you are, but don’t know where to start, I’ve put together this quick guide based on my own experience of updating my phone, an AT&T Samsung Focus.  Note: As you would expect, if you do decide to upgrade your phone, this is entirely at your own risk.

Before you begin, you’ll need a few things:

1.  A Windows Phone 7 device with all of the current updates (a.k.a. NoDo) installed.  Double check the updates in the Zune application to make sure everything is up to date.  You should see that your WP7 build number is 7390.

2.  Zune Software 4.7.1404.  Although 4.8 was released yesterday, you won’t be able to do the update with this version (yet).  Download 4.7.1404 from here if needed.

3.  Windows Phone 7 Support Tools.  You can download this from here (32bit, 64bit).  Run the installer, but you don’t need to run the application.

4.  Enough battery power to get you through several updates (when the phone is updating, your device isn’t being charged).  I would avoid trying this with anything less than 50% charge.

5.  The mango update tools.  If you are a registered Windows Phone 7 developer, you can supposedly download these from the Microsoft Connect site.  If you are not (or like me you are, but couldn’t find the tools on Connect), you can find a version of the tools on this site.  (Note:  Follow Step 1, and yes, you have to wait for 45 seconds for the download link to work).

With all of the above in place, run the Update.bat from the Mango update tool download.  Assuming there are no errors, you should see something similar to the following.

image

Firstly, the tool will make a backup of your device to the c:\PreMangoState2 directory, and install the updates necessary for your device to receive the pre-release Mango bits.  The time this will take may vary, but on my machine it took 112 seconds to backup, and 70 seconds to update the device.

Once the batch file completes, and the device reboots, the Zune software should automatically launch.  You’ll be shown that an update is available (likely build 7403).

image

Choose to install this, which will then download the Zune 4.8 software.  After the Zune software has been updated, the phone will be updated to 7403, which should be a fairly quick update.

As the phone reboots once more, the Zune software will do another check – and this time will pick up the 7712 build, which is Mango RC.  Choose to download and install this one.  This is where the battery power is important, as this install can take quite a bit of time to complete (let’s just say that I’ve been able to pen this blog post, and it’s still not 75% of the way there!).

Be patient though – one final reboot, and you’ll be running the latest Mango RC (Build 7712) bits!  Enjoy!

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Meet me for lunch!

I’m on the road for the next few weeks, visiting locations across the US, holding a series of “Mobility lunches”.  These lunches are a great way to get up to speed with what mobility means for your organization – from the current state of the mobile market, handsets, tablets, through to building applications and solutions for your own employees and customers.

Each event is held over lunch, and it’s a great opportunity to network with peers in your region as well as folks from the local Neudesic office.  Here is the schedule – it’s free to attend, although you do have to register!  Look forward to seeing you there!

April 19 – San Diego

April 20 – Los Angeles

April 26 – Denver

April 27 – Las Vegas

April 28 – Phoenix

May 5 – Orange County

May 10 – Chicago

May 11 – New York

May 12 – Philadelphia

May 31 – San Francisco

June 1 – Seattle

June 7 – Dallas

June 8 – Houston

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Webcast: The Future of Mobility

Thanks to everyone that viewed my “Future of Mobility” webcast this morning.  It was a lot of fun to put together, and it was great to see so many attended.

If you didn’t have chance to catch the live webcast this morning, you can click here to watch the recorded version.  I’ve also posted the slides (yes, 139 of them!) up to my SlideShare account.

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Mobility Panel–“Mobile Business Apps”

Are you in or around the Irvine, CA area on Wednesday January 19th 2011? 

If so, you may want to attend an evening panel session on  Where mobile business applications are headed in 2011.  I’ll be presenting together with Kevin Boyle from Microsoft, Autumn Radtke from Geodelic, and Jack Bicer from Septium.  The event is catered, and I think it’s going to be a lively and engaging discussion!

Click here for more information, and here to register.

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Upcoming Mobility WebCasts

For those interested, I’m going to be hosting a couple of mobility-related webcasts in the next couple of months.  You can find the details below. 

I’m really looking forward to them, and hope you are able to join!  Click on the titles to register for the events.

The Future of Mobility

1/25/2011 (10am – 11am PST)

In the few seconds that it takes you to read this abstract, Apple will have sold another 54 iPhones and 11 iPads. Did you know there are over 80 unique Android handsets available from carriers today, and by the end of this month, over 30 Android slates will be available for purchase. Although a little late to the party, Microsoft is also not giving up and is reportedly spending $1bn marketing and developing Windows Phone 7.
 
In this Webast, the first of a new Mobility series from Neudesic, we’ll build on these amazing facts by exploring the emerging trends around mobile device adoption, discovering the types of enterprise applications that people are building today, the challenges they face, and concluding by sharing thoughts on the incredible opportunities for your organization in this fast moving area.

Mobile Business Intelligence

2/22/2011 (10am – 11am PST)

Many analysts are predicting that 2011 will be a tipping point for mobile devices embracing BI. Given the adoption of mobile devices across organizations, in many cases led by the CxO level, it’s hard to argue. But what does BI really look like on mobile devices? Given the screen real estate and touch form factors, what can be accomplished today, and what’s better left to the desktop instead? In addition, what are the factors affecting integration and connection with back end reporting systems?

In this Webcast, part of a new Mobility series from Neudesic, we’ll look at the factors that make BI successful on mobile devices, understand the market landscape for BI solutions today, and cover some of the opportunities and challenges of implementing a mobile BI solution in your own organization.

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Getting Authentication Working with WCF and WP7

Although Windows Phone 7 (WP7) has support for a Windows Communication Foundation (WCF) client, connecting to Web services that require authentication can be a little quirky. 

After working on a project over the holidays putting together a WP7 client to connect to a Web service requiring authentication, this is what I found:

1.  NTLM/Kerberos is a no go…

As of today, the WCF client on WP7 does not support NTLM or Kerberos authentication.  If you are accessing Web services from a device, you’ll want to make sure that the your server  is setup to handle Basic authentication (preferably over SSL).

2.  And even Basic authentication needs a helping hand…

Even with Basic authentication enabled on the server, I was noticing that the client was still not sending the right HTTP headers – even when setting the ClientCredentials property on the client and playing with the config file.  No matter what I tried, I couldn’t get it to work.

To overcome this however, you can force the Basic authentication details to be written as part of the request header.  To do this, first create a method that generates a UTF8 encoded string for your domain, username, and password:

public static string GetCredentials(string domain, string username, string password)
{    

return Convert.ToBase64String(Encoding.UTF8.GetBytes(String.Format(@"{0}{1}:{2}",domain,username,password)));      
}

Then, you’ll need to create a new property with your credentials:

HttpRequestMessageProperty request = new HttpRequestMessageProperty(); request.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " + GetCredentials;

Finally, add the header to your outgoing request:

OperationContextScope clientScope = new OperationContextScope(client.InnerChannel); OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, request);

(in the above client is your service reference)

And voila!  You should now have Basic authentication headers as part of your client requests, and you can access username/password protected Web services from your WP7 device!


One final tip – during all of this you will likely need to use a tool like Fiddler to trace your requests and responses from the device.  If you are having troubles getting Fiddler working with the WP7 emulator, here is a great post that outlines what to do.

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Feeling the Pulse at Neudesic!

I’ve just passed the two week mark here at Neudesic. As anyone who has changed companies knows, getting up to speed with the internal workings of a new organization can be like drinking from a firehose!

One of the most interesting things I’ve come across to date is an application called Pulse.

clip_image002

In essence, Pulse is Facebook for the enterprise. If you’ve ever used Facebook or another social networking site, the feeds, profiles, walls, likes, follows, etc. will all feel very similar.

One of the main differences however is that because the social network is inside the walls of an enterprise, the possibilities for extending become so much more interesting. Not only can you “friend” other colleagues, but you can also “friend” systems. Like to know when business is won or lost? “Friend” the CRM system, and if someone updates an opportunity, you get a pulse notification. Similarly, if someone joins or leaves the company, the HR system “pulses” about the change. Are the IT Systems going down for routine maintenance? You’ve guessed it… another pulse! I’m sure there are many additional directions that this could be taken – just think of the countless internal systems that we habitually visit every day. What if each of them could send push notifications into a central social network?

Another feature of Pulse is the ability to converse on external feeds. Pulse can monitor external feeds (anything exposed through RSS or ATOM) and bring them within the walls of the company. The beauty here is not the ability just to subscribe to this external information, but the ability to comment on these within the organization. For example, last week, a few colleagues and I were chatting about a post on Engadget. Rather than the “old way” where someone forwards the link via email to a closed group of people, we were discussing this via a thread in Pulse. Not only does this allow the topic to be shared with others, but it also makes it available for future subscribers to find. If someone new joins the company and subscribes to the Engadget feed via Pulse, they can discover the exact internal conversation that happened around that post. This is something that would be near impossible to do with email.

Of course, my favorite feature of Pulse has to be the mobile client. Our product team has done a phenomenal job publishing clients for iOS, Android, Blackberry, and will have a WP7 version available very soon.

clip_image004clip_image006clip_image008clip_image010

Finally, you may be interested to know that Pulse is not only an internal system here at Neudesic, but is a commercial product that can be used for organizations of all sizes – from a few users to tens of thousands.

If you are interested in learning more, I would recommend going to this site – alternatively just drop me a line, and I’ll connect you with the right people!

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Test Driven Development (TDD) and Windows Phone 7

Kylen, my 6 year old son, is really into world flags. At home we have a sheet of around 200 flags from across the globe, and he’s pretty close at reciting all of them (and certainly much better than Mom and Dad!).

Spending a couple of hours over labor day last month, I set myself a task of building a “Flag Matching” application for Windows Phone 7 (WP7). My goal was twofold: Build a simple application that he can use (and that I can offer on the marketplace), and at the same time, look into some of the TDD best practices for developing a WP7 application.

imageThe application itself is simple enough. As shown above, the player gets presented with a picture of a flag, and four possible countries (of which only one is correct). A game consists of 20 flags, and the application maintains a high score table.

During development of the application, this is what I found:

1. Setting up TDD for Windows Phone 7

As a new developer for Windows Phone 7, one of the first things you’ll quickly discover is that there is no option for a test project within the IDE. After creating a WP7 solution, I searched for the “WP7 Test Project” template, but to no avail…

imageA quick search on the Web will offer up a few alternatives and chances are, you’ll quickly reach Jeff Wilcox’s session on Unit Testing Silverlight & Windows Phone Applications from MIX10. This is a really good session, however the recommended approach (using a Silverlight-based unit test framework) can be somewhat limited.

In my opinion, although it works well for small numbers of tests, not having unit tests outside the emulator makes it difficult for large test suites, using any continuous integration, and integrating with the IDE.

If unit tests in the emulator don’t work for you either, here’s a workaround:

In your solution, create a new project of type Windows Phone Class Library.

imageName it appropriately (I called mine FlagMatch.Test) and include a reference to the original Windows Phone project (FlagMatch). Add the NUnit unit test framework library as a reference (I’m using v2.0.50727) and write your tests as you normally would (of course, specific to the NUnit syntax).

[TestFixture]
public class FlagModelTests
{
    [Test]
    public void TestFourRandomFlags_AllUnique()
    {
        Assert.AreEqual(4, Flag.FourRandom.GroupBy(f => f.Name).Select(f => f).Count());
    }
}

Once you have a set of tests, you can then integrate these within Visual Studio. I’ve had reasonable luck with Visual NUnit, a free IDE plug in that works well with many versions of Visual Studio.

imageAlternatively, if you use ReSharper, you’ll find that their IDE integration works great also.

imageMy preference is to use ReSharper as it works well with with another JetBrains product called dotCover – for which you can use to analyze test code coverage in your Windows Phone application.

Although you’ll find the majority of your unit tests will work great, you may well come across some strange errors. Most of these will be related to operations on the phone that cannot be replicated outside the emulator. For example, accessing isolated storage or referring to embedded resources/images as part of the project works well within the emulator, but not so much from a class library.

To get around this, you’ll need to create some mock objects to handle these operations. In my test project, I have a MockStorageProvider that I use in place of calls to isolated storage:

[Test]
public void TestResumeButton_NotVisibleOnStartup()
{
    MainViewModel viewModel = new MainViewModel(new MockStorageProvider());
    Assert.AreEqual(Visibility.Collapsed, viewModel.ResumeGameButtonVisibility);
}

As you can see, I pass the mock object to the view model (more on this in the next section) as an optional constructor parameter. All storage operations then use this MockStorageProvider instead of writing to isolated storage (which would have generated an exception during the tests). This also has the advantage that I can add additional tests within the mock object to ensure that the storage provider is being called correctly from the application.

2. Using MVVM with WP7

For anyone with experience of testing Silverlight projects, you’ll know that although XAML provides a code separation layer, testing parts of the UI (e.g. actions when a button is pressed) can still be difficult. This can be overcome by using a pattern called MVVM (Model View ViewModel). I’m not going to go into the details of MVVM here (there are plenty of other resources that do a great job) other than to say it can be used for WP7 applications with a little tweaking. The core reason is that WP7 is based largely on the SL3 codebase, which does not contain a complete commanding event model.

There are a couple of approaches in order to get MVVM working on WP7. The first would be to reuse one of the existing samples/libraries available today. Your mileage may vary (as I found some were designed for pre-RTM versions), although I’ve heard good reviews about Laurent Bugnion’s MVVMLite project.

If instead you’d like to learn how implement this yourself, here is how I achieved it:

First, you should create a view model base. Assuming you are going to have multiple view models (I ended up with one per page), it’s a good idea.

public class ViewModelBase : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public void NotifyPropertyChanged(String propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

Next, create your view model, inheriting from ViewModelBase.

public class MainViewModel : ViewModelBase
{
    public string NewGameButtonTitle
    {
        get { return AppResources.NewGameButtonTitle; }
    }

    public NewGameCommand NewGameButton
    {
        get
        {
            return new NewGameCommand();
        }
    }
}

For the purposes of this sample code, let’s imagine that we have a single page with a “New Game” button. As you can see above, the view model contains two properties – one for the title of the button, the second for the command that this button will be bound to.

In order to implement the commands, you’ll need a couple of things. The first is a command service:

public static class CommandService
{
    private static readonly DependencyProperty _commandProperty;

    static CommandService()
    {
        _commandProperty = DependencyProperty.RegisterAttached("Command", typeof(ICommand), typeof(CommandService),
        new PropertyMetadata(OnCommandChanged));
    }

    public static ICommand GetCommand(DependencyObject dependencyObject)
    {
        return (ICommand)dependencyObject.GetValue(_commandProperty);
    }

    public static void SetCommand(DependencyObject dependencyObject, ICommand value)
    {
        dependencyObject.SetValue(_commandProperty, value);
    }

    private static void OnCommandChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dpceArgs)
    {
        if (dependencyObject is Button)
        {
            string parameter = dependencyObject.GetValue(_commandProperty).ToString();
            Button button = (Button)dependencyObject;
            ICommand command = (ICommand)dpceArgs.NewValue;
            button.Click += delegate(object sender, RoutedEventArgs arg) { command.Execute(parameter); };
        }
    }
}

There are a good number of examples of this around (just search for MVVM) – this one I found in a great post from the Coding Solutions blog.

After this, you’ll need to create event handlers. Here’s a simple handler for when the new button is pressed.

public class CommandEvents
{
    public static EventHandler NewGameButtonPressed;
}

Your command itself simply implements the ICommand interface:

public class NewGameCommand : ICommand
{
    public NewGameCommand()
    {
    }

    public bool CanExecute(object parameter)
    {
        return true;
    }

    public event EventHandler CanExecuteChanged;

    public void Execute(object parameter)
    {
        if (this.CanExecute(null))
        {
            if (CommandEvents.NewGameButtonPressed != null)
            {
                CommandEvents.NewGameButtonPressed(this, new EventArgs());
            }
        }
    }
}

With all these in place, you can now bind the command to the actual button in your XAML file. On your XAML page, you’ll need to add the following namespace:

xmlns:Commands="clr-namespace:FlagMatch.Commands"

And on the button itself, simply bind to the command using the following:

button name="button1" margin="134,505,0,0" verticalalignment="Top" commands:commandservice.command="{Binding Path=NewGameButton}" content="{Binding NewGameButtonTitle}" height="72" horizontalalignment="Left" width="227"

Notice how the content of the button is bound to the NewGameButtonTitle in the view model, and the command is bound to the NewGameButton command. More importantly, notice also how there are no traditional event handlers needed here.

The final piece of the puzzle is to register the view model and the button event handler in the XAML code behind. To do this, in the code behind, we create an instance of the view model:

private readonly MainViewModel _mainViewModel = new MainViewModel();

Then in the constructor, bind the view model to the datacontext and register the button event handler.

LayoutRoot.DataContext = _mainViewModel;

CommandEvents.NewGameButtonPressed += new EventHandler(StartGame);

The StartGame method simply performs a navigate action for us. This is something that just can’t be moved into the view model.

private void StartGame(object sender, EventArgs e)
{
    NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative));
}

Other than that, there is no additional UI logic required in code behind – which means for a slightly more complex implementation, but one that provides great test coverage.

A final point worth noting is designer support. As you start building out controls using the MVVM paradigm, you’ll likely find that the designer ends up being difficult to use.

imageBecause we are binding content directly to the view model, the designer doesn’t know where to pick up values to be shown at design time. Fortunately, there is a way around this. Simply add a reference to the view model in your App.xaml file:

Rebuild the project, and you’ll see that the designer picks up the default values from a instance of the view model class:

image3. Localization and MVVM

Finally, I wanted to make sure that my MVVM model could be used for multiple languages.

You may have noticed that in the previous code sample, the title of the button is returned as AppResources.NewGameButtonTitle (instead of returning “New Game”).

public string NewGameButtonTitle
{
    get { return AppResources.NewGameButtonTitle; }
}

This is to make localization easy (well… easier!). Under my Locales namespace there are two files:

imageAppResources.resx is a resource file that contains default (in my case English) string values. In there, you’ll find that NewGameButtonTitle refers to a string called “New Game”.

As you may have guessed, AppResources.es-ES.resx is the Spanish version of this resource file. In there, you’ll find that NewGameButtonTitle refers to a string called “Nuevo Juego”

In order to enable the Spanish localized version, we need to do a few things:

Firstly, create separate resource files for all your languages, using the AppResources.[lang].resx format as stated above.

Next, in the .resx file, ensure that the access modifier is set to public.

image(Otherwise, you’ll find that it just doesn’t offer the localized version).

Them edit your .csproj file outside Visual Studio (using Notepad or similar). Add the supported country code in the SupportedCultures tag.

es-ES

Save the file and reload the project in Visual Studio.

Once this is done, deploy the application to the emulator, and set the language of the emulator appropriately (Settings / Region and Language / Display Language). The emulator will restart.

Finally, test your application. You should find that the new language strings are now used:

image(My Spanish isn’t that good, so apologies for any mistakes above!).

One word of caution: The testing process on the Windows Phone Marketplace is strict when it comes to supporting multiple languages. If you submit an application that supports multiple languages, you really need to make sure that all strings are localized (and you provide localized screenshots and product descriptions) in order to pass the testing certification.

*** Update: I’ve recently moved the source code for the project – you can now find it on http://github.com/simonguest/flagmatch ***


  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS