-2

I have installed mango SDK in my machine and I want to create an application which runs on both Windows Phone OS 7.0 and Windows Phone OS 7.5 devices. Also I need to implement many of the mango features in the same application. Is it possible ? if yes please tell me how to do the version checking, because based on the version we need to implement the mango features.

saikamesh
  • 4,569
  • 11
  • 53
  • 93

3 Answers3

6

You'll have to maintain two different versions. You can't compile one XAP that supports both versions at the same time.

The Mango APIs are only available when compiling with the 7.1 SDK. And as such, you can't do in-line checking in the code.

But it's rather pointless, as there's almost no users left that haven't upgraded to Mango, and all new phones ship with Mango.

Claus Jørgensen
  • 25,882
  • 9
  • 87
  • 150
  • 1
    I completely agree with this if you're making an app for your own demographic; the only issue here is when working with a client, convincing them to drop 7.0 support -- the last time I checked, Microsoft hadn't released any info regarding the % of users on Mango vs 7.0. – William Melani Jan 04 '12 at 08:38
2

Now days all the Windows phone are shipping with the Wp7.5 mango version also Older devices are getting mango updates, so it looks pointless in targeting only few WP7.0 running phones.

But if you dont need to anything SDK related api access then you can do this bifurcation.

However You can find the solution to the finding the OS version is in [my answer of same kind of question here.]1

Community
  • 1
  • 1
Santhu
  • 1,535
  • 8
  • 11
2

You can do this using the Type class and reflection, although the process will not be easy. Create a Windows Phone 7.0 application, and then create a MangoExtensions class which implements the mango specific features:

http://www.sharpgis.net/post/2011/08/21/Windows-Phone-Adding-Mango-features-to-a-70-WinPhone-App.aspx

bool IsMangoDevice = (Environment.OSVersion.Version >= new Version(7, 1));

if (IsMangoDevice)
{
  Type t = Type.GetType("Microsoft.Phone.Shell.StandardTileData, Microsoft.Phone");

  //get the constructor for the StandardTileData and create a new instance of it
  var newTileData = t.GetConstructor(new Type[] { }).Invoke(null);
  //Get the setter method for the title property
  var setMethod = newTileData.GetType().GetProperty("Title").GetSetMethod();
  //Set the tile title
  setMethod.Invoke(newTileData, new object[] { "This is my new tile" });
  //Get the create method for the shell tiles
  Type shellTileType = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");
  var createMethod = shellTileType.GetMethod("Create");
  //Create the tile, with the uri and tile data
  Uri uri = new new Uri("/MainPage.xaml?Test=This_Came_From_A_Secondary_Tile", UriKind.Relative)
  createMethod.Invoke(null, new object[] {  uri, newTileData});
}
terphi
  • 781
  • 7
  • 18