Frage

I'm developing app for Windows Phone 8, and i'm trying to share image via ShareMediaTask. The procedure? that i use for it is as follows :

    private static Microsoft.Phone.Tasks.ShareMediaTask shareMediaTask;



    public static void shareCurrentCroppedImage ()
    {
        shareMediaTask = new Microsoft.Phone.Tasks.ShareMediaTask();
        GC.Collect();
        Debug.WriteLine("file path : {0}", currentFileName);
        shareMediaTask.FilePath = currentFileName;
        shareMediaTask.Show();
    }

The path from console looks like this:

file path : C:\Data\Users\Public\Pictures\Saved Pictures\Lo_1.jpg

Unfortunately, when i call this proc ( from button click event ) the app shuts down, a black screen shows, but then suddenly workflow returns back to my app without any sharing UI. How can i fix this issue? Any help would be appreciated!

War es hilfreich?

Lösung

This is the code which worked for me.. I had created a PhotoChooserTask to capture an image or open an existing image from library and then when this PhotoChooserTask completes, I create a ShareMediaTask and set its Filepath property to The "OriginalFileName" filed from the parameter photoresult e. The issue with your code, i think, might be this path of image.

    private void OnShareMediaTaskClicked(object sender, RoutedEventArgs e)
    {
        var photoChooserTask = new PhotoChooserTask { ShowCamera = true };
        photoChooserTask.Completed += OnPhotoChooserTaskCompleted;
        photoChooserTask.Show();
    }

    void OnPhotoChooserTaskCompleted(object sender, PhotoResult e)
    {
        var photoChooserTask = (PhotoChooserTask)sender;
        photoChooserTask.Completed -= OnPhotoChooserTaskCompleted;

        var shareMediaTask = new ShareMediaTask ();
        shareMediaTask.FilePath = e.OriginalFileName;
        shareMediaTask.Show();
    }

I have set the OnShareMEdiaClicked as ahandler of an onClick event for a button. and the rest flow is clear. Hope this helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top