android - SQLiteException trying to load a contact photo with Picasso -


i'm getting following error on devices when trying load contact photos in cursoradapter:

java.lang.runtimeexception: unexpected exception occurred @ com.squareup.picasso.request$1.void run()(unknown source) @ android.os.handler.handlecallback(handler.java:605) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4514) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:790) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:557) @ dalvik.system.nativestart.main(native method) caused by: android.database.sqlite.sqliteexception: near "and": syntax error: , while compiling: select distinct data15 view_data_restricted data ( , _id=photo_id1 , _id=photo_id , contact_id=?) @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:179) @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:135) @ android.content.contentproviderproxy.query(contentprovidernative.java:358) @ android.content.contentresolver.query(contentresolver.java:321) @ android.provider.contactscontract$contacts.opencontactphotoinputstream(contactscontract.java:1968) @ com.squareup.picasso.utils$contactphotostreamics.java.io.inputstream get(android.content.contentresolver,android.net.uri)(unknown source) @ com.squareup.picasso.utils.boolean parseresponsesourceheader(java.lang.string)(unknown source)                           java.io.file createdefaultcachedir(android.content.context)                           java.io.inputstream getcontactphotostream(android.content.contentresolver,android.net.uri) @ com.squareup.picasso.picasso.android.graphics.bitmap loadfromtype(com.squareup.picasso.request)(unknown source) @ com.squareup.picasso.picasso.android.graphics.bitmap resolverequest(com.squareup.picasso.request)(unknown source) @ com.squareup.picasso.picasso.void run(com.squareup.picasso.request)(unknown source) @ com.squareup.picasso.request.void run()(unknown source) @ java.util.concurrent.executors$runnableadapter.call(executors.java:442) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:305) @ java.util.concurrent.futuretask.run(futuretask.java:137) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1076) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:569) @ java.lang.thread.run(thread.java:856) @ com.squareup.picasso.utils$picassothread.void run()(unknown source) 

the sql query being used photo stream invalid.

here's how i'm loading image:

query contactscontract:

public static final string[] projection = { contacts._id, contacts.lookup_key, contacts.display_name_primary,         contacts.photo_thumbnail_uri, contactscontract.commondatakinds.email.data }; public static final string selection = contactscontract.commondatakinds.email.data + " <> '' , "         + contacts.in_visible_group + "=1"; public static final string order_by = contacts.sort_key_primary;  @override public loader<cursor> oncreateloader(int loaderid, bundle args) {     return new cursorloader(this, contactscontract.commondatakinds.email.content_uri, projection, selection, null,             order_by); } 

pass resulting cursor adapter. contact photo uri so:

uri photouri = contacts.getlookupuri(cursor.getlong(cursor.getcolumnindex(contacts._id)),                 cursor.getstring(cursor.getcolumnindex(contacts.lookup_key))); 

load photo using picasso:

picasso.with(context).load(photouri).placeholder(r.drawable.ic_contact_picture).into(photo); 

as said, exception occurs on devices. wrapping picasso call in try/catch unfortunately nothing, because image being loaded asynchronously. create asynctask , load image synchronously, what's point of using picasso?

cloning updated picasso code , building jar myself fixed problem. i've heard they're planning new official release soon.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -