LockScreen for windows phone 8

uncle_scrooge

Hi I am developing a lockscreen app where I am using listbox of images.After selecting a image when i am clicking a button to set lockscreen,It should updated.But it bot updating .Here is my code

private async void ApplicationBarIconButton_Click(object sender, EventArgs e)
    {
        MediaLibrary mediaLibrary = new MediaLibrary();
        //ImageSource im = image1.Source;
        BitmapImage bitmap = new BitmapImage();
        bitmap.SetSource(mediaLibrary.Pictures[imageList.SelectedIndex].GetImage());

        String tempJPEG = "MyWallpaper1.jpg";

        using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
        {
            if (myIsolatedStorage.FileExists(tempJPEG))
            {
                myIsolatedStorage.DeleteFile(tempJPEG);
            }

            IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(tempJPEG);

            StreamResourceInfo sri = null;
            Uri uri = new Uri(tempJPEG, UriKind.Relative);
            sri = Application.GetResourceStream(uri);

            WriteableBitmap wb = new WriteableBitmap(bitmap);

            Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 90);

            fileStream.Close();
        }

        LockScreenChange(tempJPEG);

    }

    private async void LockScreenChange(string filePathOfTheImage)
    {
        if (!LockScreenManager.IsProvidedByCurrentApplication)
        {
            await LockScreenManager.RequestAccessAsync();
        }

        if (LockScreenManager.IsProvidedByCurrentApplication)
        {
            var schema = "ms-appdata:///Local/";
            var uri = new Uri(schema + filePathOfTheImage, UriKind.Absolute);

            LockScreen.SetImageUri(uri);
            var currentImage = LockScreen.GetImageUri();
            MessageBox.Show("Success", "LockScreen changed", MessageBoxButton.OK);
        }
        else
        {
            MessageBox.Show("Background cant be changed. Please check your permissions to this application.");
        }
    }

Actually when first time the app is launched and when I am clicking set button,the current selected image is set as lockscreen,after that when i am selecting another image,it is showing lockscreen changed ,success.No error and no exception.I dont know where is the problem. Please help........

uncle_scrooge

It got solved by changing temporary file name to original file name i.e. string tempJpeg

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related