error creating a Square310x310Logo tile when image is from web

672 Views Asked by At

I'm trying to create a secondary tile for a windows 8.1 application, i need this tile to contain images for all sizes and all of them come from internet. this is my code :

       string dynamicTileId = selectedItem.UniqueId;
        string sLogo = selectedItem.logo;
        string wLogo = selectedItem.widelogo;
        string lLogo = selectedItem.imagen3;



        Uri logo = new Uri(sLogo);//150x10 image
        Uri wideLogo = new Uri(wLogo);//310x150 image
        Uri largeLogo = new Uri(lLogo);//310x310 image
        string tileActivationArguments = dynamicTileId;


        var secondaryTile = new SecondaryTile(dynamicTileId, selectedItem.Title, tileActivationArguments, largeLogo, TileSize.Square310x310);

        secondaryTile.VisualElements.ForegroundText = ForegroundText.Light;
        secondaryTile.VisualElements.BackgroundColor = Colors.CadetBlue;
        secondaryTile.VisualElements.Square310x310Logo = largeLogo;
        secondaryTile.VisualElements.Square150x150Logo = logo;
        secondaryTile.VisualElements.Wide310x150Logo = wideLogo;



        await secondaryTile.RequestCreateAsync();

I'm having this error while the app tries to use the 310x310 logo:

WinRT information: Could not initialize secondary tile with provided arguments.

All the other images work fine. I'm using this picture for testing : http://www.usatodayeducate.com/staging/wp-content/uploads/2013/03/310x310-0313-gapyear.jpg

if i comment the line that includes the 310x310 logo everything works fine. Any idea why this is happening?

3

There are 3 best solutions below

1
On

You cannot link to web resources. They must be either local in the app (A path within the deployed app package. This path is resolved for languages and DPI plateau supported by the app.) or on the user device (A file found in the per-user app storage.).

Documentation of this: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.startscreen.secondarytilevisualelements.square310x310logo.aspx

2
On

As per the SecondaryTile class

public SecondaryTile(string tileId, string displayName, string arguments, Uri square150x150Logo, TileSize desiredSize);

where

desiredSize:The size of tile to pin. This value must be Default (which provides Windows 8 behavior), Square150x150, or Wide310x150. Any other TileSize value causes an exception to be thrown during runtime.

Here you used 310x310 size for desiredSize which is not acceptable by the Secondary tile.
Please check your code.

0
On

looks that you're using a high dpi image, 300 dpi. I was reviewing the image and the unique attribute looking unusual is image dpi (high).

Try using same image in traditional screen 96 dpi, you could try with this one I have conveted to 96 dpi: enter image description here