Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

MediaPicker TakePhoto is not working for Sony Experia L #21

Closed
zleao opened this issue Nov 27, 2013 · 9 comments
Closed

MediaPicker TakePhoto is not working for Sony Experia L #21

zleao opened this issue Nov 27, 2013 · 9 comments
Assignees
Milestone

Comments

@zleao
Copy link

zleao commented Nov 27, 2013

I've deployed the MediaPicker Sample to a Sony Experia L, and the Take Photo option is not working. The app does not crash. The camera capture window is shown, but after the capture, the resulting image is not shown.
After some debugging, I've realised that in the method TryMoveAsyncFile(Context context, Uri url, Uri path, bool isPhoto) the source and destination path's are the same. Because of that, the following lines will produce a FileNotFoundException:

File.Delete(moveTo);
File.Move(t.Result.Item1, moveTo);

I've added a simple test before the File.Delete and File.Move, to check if the paths are equal. It looks something like:

if(moveTo != t.Result.Item1)
{
    File.Delete(moveTo);
    File.Move(t.Result.Item1, moveTo);
}

I'm not sure if this is the best place to solve this bug. Not sure if the execution should reach this point in this case scenario.
Any insights?

@zleao
Copy link
Author

zleao commented Nov 27, 2013

I've just realized that this issue is somewhat related to #17
This was posted a month ago, and there was no reply...

@ermau
Copy link
Member

ermau commented Dec 2, 2013

Was able to confirm this on an Experia Mini, investigating.

@ghost ghost assigned ermau Dec 2, 2013
@ermau
Copy link
Member

ermau commented Dec 2, 2013

I'm not sure if this is the best place to solve this bug. Not sure if the execution should reach this point in this case scenario.

It's not as you're right, it shouldn't. It looks like that the Experia's camera app is respecting EXTRA_OUTPUT, but providing back the path anyway which is different than some other apps. Unfortunately, I don't have an Experia device in front of me. @zleao can you try this fix instead?

--- a/MonoDroid/Xamarin.Mobile/Media/MediaPickerActivity.cs
+++ b/MonoDroid/Xamarin.Mobile/Media/MediaPickerActivity.cs
@@ -158,11 +158,11 @@ namespace Xamarin.Media

                                // Not all camera apps respect EXTRA_OUTPUT, some will instead
                                // return a content or file uri from data.
-                               if (data != null) {
+                               if (data != null && !data.Equals (path)) {

@zleao
Copy link
Author

zleao commented Dec 2, 2013

I'm currently on a short 2 day vacation and I'll only be able to test it on Wednesday 4th of December. If no one tries it before, I'll give my feedback Wednesday morning.

Thank you for the help!

José Pereira


From: Eric Maupinmailto:[email protected]
Sent: ý02/ý12/ý2013 21:13
To: xamarin/Xamarin.Mobilemailto:[email protected]
Cc: José Pereiramailto:[email protected]
Subject: Re: [Xamarin.Mobile] MediaPicker TakePhoto is not working for Sony Experia L (#21)

I'm not sure if this is the best place to solve this bug. Not sure if the execution should reach this point in this case scenario.

It's not as you're right, it shouldn't. It looks like that the Experia's camera app is respecting EXTRA_OUTPUT, but providing back the path anyway which is different than some other apps. Unfortunately, I don't have an Experia device in front of me. @zleaohttps://github.com/zleao can you try this fix instead?

--- a/MonoDroid/Xamarin.Mobile/Media/MediaPickerActivity.cs
+++ b/MonoDroid/Xamarin.Mobile/Media/MediaPickerActivity.cs
@@ -158,11 +158,11 @@ namespace Xamarin.Media

                            // Not all camera apps respect EXTRA_OUTPUT, some will instead
                            // return a content or file uri from data.
  •                           if (data != null) {
    
  •                           if (data != null && !data.Equals (path)) {
    


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-29658008.

@zleao
Copy link
Author

zleao commented Dec 4, 2013

I ran a quick test with the changes you proposed and it works ok in a Sony Experia L.
I've also tried it with a Samsung Tab 2 and a Samsung Ace and it's also working fine.
Thanks!

@ermau
Copy link
Member

ermau commented Dec 4, 2013

@zleao Just to be clear, you removed your changes first right?

@zleao
Copy link
Author

zleao commented Dec 5, 2013

Yes @ermau , I removed my changes and tried only with yours

@julcol
Copy link

julcol commented Dec 6, 2013

I had the same problem with the Motorola Razr XT 910. I made the change in my code and now it works! Thanks a lot

@ermau
Copy link
Member

ermau commented Dec 6, 2013

Fixed in 0c0b70e

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants