enisn/Xamarin.Forms.Contacts

How to load the PhotoUri ?

Opened this issue · 6 comments

For instance, on Android that I am testing now, I got the result content://com.android.contacts/contacts/120

How to show this image ?

For instance, on Android that I am testing now, I got the result content://com.android.contacts/contacts/120

How to show this image ?

did u resolve it? because I need help too.

Photo uri is empty

Update: In Android I can get photo uri, but in iOS It is empty.

Looks like on iOS it uses CNContact which doesn't contain PhotoUri.
CNContact has ThumbnailImageData and ImageData which are raw data.
Here:
https://github.com/enisn/Xamarin.Forms.Contacts/blob/master/Plugin/ContactService/Shared/Contact.cs
We may need to add other properties in Contact class to store raw data for iOS.
https://github.com/enisn/Xamarin.Forms.Contacts/blob/master/Plugin/ContactService/Platforms/iOS/ContactServiceImplementation.cs
Also read these raw data from CNContact object and add it into Contact object.

I think the answer @marcelocferdeveloper and @andyvasilevich are looking for is:

var u = Android.Net.Uri.Parse(uri); // e.g. content://com.android.contacts/contacts/120
img.Source = ImageSource.FromStream(() => Android.App.Application.Context.ContentResolver.OpenInputStream(u));

I'm still working on iOS, but I appreciate @gaocan1992 's last comment