java - Get Google+ profile picture from Uri to Bitmap on Android -


i using google+ sign in instance of googlesigninaccount , can correctly load users name , email without issues, know correctly set up. uri of users profile picture , trying set icon imagebutton.

the variable userphoto android.net.uri grabbed googlesigninaccount. photo, clear, not present on device.

this code i'm using right no avail:

profilebutton = (imagebutton) navheaderview.findviewbyid(r.id.navheadermainimagebutton);      try {         bitmap bitmap = mediastore.images.media.getbitmap(this.getcontentresolver(), userphoto);         profilebutton.setimagebitmap(bitmap);     } catch (ioexception e) {         e.printstacktrace();     } 

this error get:

    w/system.err: java.io.filenotfoundexception: no content provider: https://lh5.googleusercontent.com/-s7xguonbdrk/aaaaaaaaaai/aaaaaaaafv8/htgjmty1xd8/photo.jpg     w/system.err:     @ android.content.contentresolver.opentypedassetfiledescriptor(contentresolver.java:1117)     w/system.err:     @ android.content.contentresolver.openassetfiledescriptor(contentresolver.java:970)     w/system.err:     @ android.content.contentresolver.openinputstream(contentresolver.java:695)     w/system.err:     @ android.provider.mediastore$images$media.getbitmap(mediastore.java:859)     w/system.err:     @ com.seranth.sertutor.mainactivity.oncreate(mainactivity.java:136)     w/system.err:     @ android.app.activity.performcreate(activity.java:6500)     w/system.err:     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1120)     w/system.err:     @ android.app.activitythread.performlaunchactivity(activitythread.java:3072)     w/system.err:     @ android.app.activitythread.handlelaunchactivity(activitythread.java:3218)     w/system.err:     @ android.app.activitythread.access$1000(activitythread.java:198)     w/system.err:     @ android.app.activitythread$h.handlemessage(activitythread.java:1676)     w/system.err:     @ android.os.handler.dispatchmessage(handler.java:102)     w/system.err:     @ android.os.looper.loop(looper.java:145)     w/system.err:     @ android.app.activitythread.main(activitythread.java:6837)     w/system.err:     @ java.lang.reflect.method.invoke(native method)     w/system.err:     @ java.lang.reflect.method.invoke(method.java:372)     w/system.err:     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1404)     w/system.err:     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1199)     w/resources: converting string: typedvalue{t=0x5/d=0x3801 a=1 r=0x10500d1}     w/openglrenderer: program(5ea33b00) : invalid binary - source difference(vs(201:201)/fs(94:36705)-b0000000800000000) 

if follow link thrown error file not found find photo (that's me btw): https://lh5.googleusercontent.com/-s7xguonbdrk/aaaaaaaaaai/aaaaaaaafv8/htgjmty1xd8/photo.jpg

so question really, why doesn't code above work , there way of getting bitmap uri?

i can of course url of photo uri , download device, i'm hoping not have that. if solution know of please supply working code samples of how download url file , how convert downloaded url bitmap.

i suggest way, using imageview instead, can call setonclicklistener on imageview.

private void handlesigninresult(googlesigninresult result) {         if (result.issuccess()) {         // signed in successfully, show authenticated ui.         googlesigninaccount acct = result.getsigninaccount();         ...         uri uri = acct.getphotourl();         picasso.with(mcontext)                 .load(uri)                 .placeholder(android.r.drawable.sym_def_app_icon)                 .error(android.r.drawable.sym_def_app_icon)                 .into(mprofileimageview);         // call mprofileimageview.setonclicklistener();...          updateui(true);     } else {         // signed out, show unauthenticated ui.         updateui(false);     } } 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -