The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Camera/Photo Chooser task runs on emulator, but not on device RRS feed

  • Question

  • When I try to use the camera / photo chooser tasks, they both run perfectly fine on the emulator but do nothing on the device.  Has anyone else had issues with this?

    private void PhotoFromLibraryButton_Click(object sender, RoutedEventArgs e) 
            { 
                (App.Current as App).SaveData(); 
     
                PhotoChooserTask photoChooserTask = new PhotoChooserTask(); 
                photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed); 
     
                try { photoChooserTask.Show(); } 
                catch (System.InvalidOperationException ex) 
                {  
                    MessageBox.Show(ex.Message.ToString()); 
                } 
            } 
     
            void photoChooserTask_Completed(object sender, PhotoResult e) 
            { 
                filename = null
                //newBmp = null; 
     
                (App.Current as App).LoadData(); 
                if (e.TaskResult == TaskResult.OK) 
                { 
                    newBmp.SetSource(e.ChosenPhoto); 
                    Photo.Source = newBmp; 
                } 
            } 
     
            private void TakePictureButton_Click(object sender, RoutedEventArgs e) 
            { 
                (App.Current as App).SaveData(); 
     
                CameraCaptureTask cameraTask = new CameraCaptureTask(); 
     
                cameraTask.Show(); 
                cameraTask.Completed += new EventHandler<PhotoResult>(cameraTask_Completed); 
            } 
     
            void cameraTask_Completed(object sender, PhotoResult e) 
            { 
                (App.Current as App).LoadData(); 
                if (e.TaskResult == TaskResult.OK) 
                { 
                    MediaLibrary library = new MediaLibrary(); 
                    Random r = new Random(); 
                    Picture pic = library.SavePicture("SavedPicture_" + r.Next(11, 99).ToString() + ".jpg", e.ChosenPhoto); 
                    BinaryReader reader = new BinaryReader(e.ChosenPhoto); 
                    Photo.Source = new BitmapImage(new Uri(e.OriginalFileName)); 
                } 
            } 

    Thursday, October 27, 2011 7:22 PM

Answers

All replies