I have a string of html that I am placing into a WebView widget, and I
want to put a local contact photo into it.

I understand that if the picture is on sdcard, I would need to put it
into a content provider first, and then reference that...
Not in my case, as the photo IS ALREADY in the contacts content
provider.

I do not need to know how to get the bitmap out of the contacts,
because i already know how to do that!

I have gotten a uri of the photo like
content://com.android.contacts/data/phones/filter/##########/photo,
and some others similar to that, but i have noticed that there is no
real file name there, and every thing that I have been looking at says
that there should be a filename there. And then,of course I get the
error that there is no file there. Imagine that!

has anybody else run into this? Is there a filename that i can plug in
there? or is this hopeless and i should just get the bitmap, save it
into my own content provider, and then display it? THAT SEEMS LIKE A
CRAZY FIX!

here is  my little bit of code

to get the uri of the contact photo (This works when i get the bitmap
that is also shown in there)

                                        Cursor cur = 
context.getContentResolver().query(
                                                Uri.withAppendedPath
 
(ContactsContract.Contacts.CONTENT_URI,
 
Uri.encode(Globals.number)),
                                                                new String[]
{ PhoneLookup._ID},
                                                null, null, null);

                                if (cursor != null  &&
cur.moveToFirst())
                                {
                                      retval =
Long.parseLong(cur.getString(0).trim());

                                }

                                ContentResolver cr =
context.getContentResolver();
                                Cursor curso =
cr.query(ContactsContract.Contacts.CONTENT_URI, null,
                                    "DISPLAY_NAME = '"+ info.name +
"'", null, null);

                                if (curso.moveToFirst()) {
                                    String contactId =
 
curso.getString(curso.getColumnIndex(ContactsContract.Contacts._ID));
                                    //
                                    // Get the contact photo.
                                    //
                                    Uri uri =
ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,
                                        Long.parseLong(contactId));


                                    InputStream input =
 
ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);

                                    Bitmap contactPhoto =
BitmapFactory.decodeStream(input);

                                    info.photoLocalUri =
Uri.withAppendedPath(contactRef,
ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);


then to display the html, i am just using a string with....

                        htmlSummary =  "<h1>Header</h1><p>Custom 
HTML</p><p><img src=
\"content://com.android.contacts/data/phones/filter/2068981153/photo
\" /></p>";

everything works but the photo...

there must be a way to do this, please help!

Roger L

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to