views:

155

answers:

3

I'm porting an iPhone game to Windows Phone 7, and I'm wondering how I would go about getting the phone's name? Like, on the iPhone it would be the name you had set it to in iTunes, and that's also readable in the API with (obj-c..) [[UIDevice currentDevice] name]..

Anyone know the equivalent WP7 .NET methods/properties? I can't find them on MSDN. Thanks!

+1  A: 

If you are using XNA, use the static SignedInGamers property of the Gamer class.

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gamerservices.gamer.signedingamers.aspx

Edit: I thought you meant owner's name, like their gamertag or name, instead of what they named the device.

Krisc
+1  A: 

Hey Kyle,

My guess is you are going to be working in the Microsoft.Phone.Info namespace, but they have not released members of the DeviceExtendedProperties or UserExtendedProperties classes yet.

MSDN Namespace Info

Jesse McCulloch
Thanks.. I sorta wonder how I can even access the Phone namespace? It won't let me for some reason.
Kyle
+2  A: 

You can get the manufacturer specified name of the device via:

Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceName").ToString();

Note that "There is no standard format for this string. This value may be empty."

More at: http://msdn.microsoft.com/en-us/library/ff941122(VS.92).aspx

Matt Lacey
Awesome. Looks like theres a DeviceUniqueId key in there as well, which I also need. One problem, though.. How do I even access the Phone namespace? It isn't in there in my Windows Phone 7 project. Adding a 'using Microsoft.Phone' results in an error. I wonder how this could be?
Kyle
I should add that this is an XNA game for Windows Phone 7.. I didn't think that would change what namespaces were available =(
Kyle
@Kyle if it's an XNA app you will need to add a reference to the `Microsoft.Phone.dll` assembly and then you can access the `Microsoft.Phone.Info` namespace.
Matt Lacey
Thanks for your help, Matt.
Kyle