locked
How do I get the current Apps ID as stated in the manifest? RRS feed

  • Question

  • For my universal splash screen code I need to read out the apps manifest XML file during runtime and select the splash screen background color and image to compose an extended splash screen.

    currently I am using:

    Application.splashColor = xml.selectSingleNodeNS("//m2:VisualElements/@BackgroundColor", 'xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest"')?.value
    splashImageValue = xml.selectSingleNodeNS("//m2:SplashScreen/@Image", 'xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest"')?.value.replace("\\", "/")
        


    But I would like to be more specific in my XPath selectors and include the the apps ID in my XPath:

    <Applications>
        <Application Id="App" StartPage="default.html">
          <m2:VisualElements DisplayName="Foo" Description="CheckByVoice" ForegroundText="light" BackgroundColor="#ffffff" Square150x150Logo="images\Logo.png" Square30x30Logo="images\SmallLogo.png">
            <m2:SplashScreen Image="images\splashscreen.png" />
          </m2:VisualElements>
        </Application>
      </Applications>

    So my XPath would look like this: "/Applications/Application[@id='App']/@BackgroundColor"

    I know multi-app packages are rare, but I would like my code not to fail in such scenarios.

    I have found no WinRT API to get the current apps ID. Just in the launch args there is "tileId" which is "App" in case the app was launched with the default tile. But when it was launched via a secondary tile or another contract I am out of luck.

    Thursday, May 15, 2014 10:37 PM

Answers

  • You can get the ID from CoreApplication.Id; however, I'm not sure that JavaScript apps can get to the CoreApplication.

    This isn't a scenario I would worry much about: multi-app packages are not generally supported and will be very rare. Since your code will run in the app's context you can have the app pass the app-name in initialization code to handle that case.

    --Rob

    • Marked as answer by pkursawe Friday, May 16, 2014 9:54 AM
    Friday, May 16, 2014 2:26 AM
    Moderator

All replies

  • You can get the ID from CoreApplication.Id; however, I'm not sure that JavaScript apps can get to the CoreApplication.

    This isn't a scenario I would worry much about: multi-app packages are not generally supported and will be very rare. Since your code will run in the app's context you can have the app pass the app-name in initialization code to handle that case.

    --Rob

    • Marked as answer by pkursawe Friday, May 16, 2014 9:54 AM
    Friday, May 16, 2014 2:26 AM
    Moderator
  • Of course, letting the caller specify the id is a good option. Done :)
    Friday, May 16, 2014 9:54 AM