我正在开发一款使用Android Contacts API的应用。 我的代码工作正常,但最近Play Market Feedback中的新错误开始显现。 看起来这些错误只出现在SGS3和Note2上。
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.support.v4.content.ModernAsyncTask$3.done(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: android.database.sqlite.SQLiteException: near ":<phonenumber>": syntax error (code 1): , while compiling: SELECT times_contacted, contacts_status_updates.status AS contact_status, phonetic_name, phonetic_name_style, ((CASE WHEN raw_contact_linkpriority1 > 0 THEN link_type1||'|' ELSE '' END)||(CASE WHEN raw_contact_linkpriority2 > 0 THEN link_type2||'|' ELSE '' END)||(CASE WHEN raw_contact_linkpriority3 > 0 THEN link_type3||'|' ELSE '' END)||(CASE WHEN raw_contact_linkpriority4 > 0 THEN link_type4||'|' ELSE '' END)||(CASE WHEN raw_contact_linkpriority5 > 0 THEN link_type5 ELSE '' END)) AS link, is_user_profile, snippet, raw_contact_linkpriority4, lookup, raw_contact_linkpriority5, contacts_status_updates.status_icon AS contact_status_icon, sec_custom_vibration, last_time_contacted, _id, photo_uri, display_name_source, photo_thumb_uri, agg_presence.chat_capability AS contact_chat_capability, photo_id, send_to_voicemail, display_name_alt AS display_name_reverse, name_raw_contact_id, custom_ringtone, photo_file_id, has_phone_number, link_type5, link_type4, link_type3, link_type2, contacts_status_updates.status_label AS contact_status_label, link_type1, raw_contact_linkpriority3, display_name, raw_contact_linkpriority2, raw_contact_linkpriority1, sort_key_alt, has_email, in_visible_group, dirty_contact, starred, link_count, sort_key, display_name_alt, agg_presence.mode AS contact_presence, contacts_status_updates.status_res_package AS contact_status_res_package, contacts_status_updates.status_ts AS contact_status_ts FROM view_contacts_restricted JOIN (SELECT contact_id AS snippet_contact_id, ifnull('['||(SELECT MIN(data1) FROM data JOIN raw_contacts ON (data.raw_contact_id = raw_contacts._id) JOIN phone_lookup ON data._id=phone_lookup.data_id WHERE search_index.contact_id=contact_id AND normalized_number LIKE '%+<phonenumber>%' OR normalized_number LIKE '%+<phonenumber>%')||']',snippet(search_index,'[',']','...',1,-10)) AS snippet FROM search_index WHERE search_index MATCH content:<phonenumber>* OR name:2024121E20201E14122412* UNION SELECT contact_id AS snippet_contact_id, NULL AS snippet FROM phone_lookup JOIN raw_contacts ON ( raw_contacts._id=raw_contact_id) WHERE normalized_number LIKE '%+<phonenumber>%') ON (_id=snippet_contact_id) LEFT OUTER JOIN agg_presence ON (_id = agg_presence.presence_contact_id) LEFT OUTER JOIN status_updates contacts_status_updates ON (status_update_id=contacts_status_updates.status_update_data_id)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:184)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
at android.content.ContentResolver.query(ContentResolver.java:372)
at android.content.ContentResolver.query(ContentResolver.java:315)
at android.support.v4.content.CursorLoader.loadInBackground(Unknown Source)
at android.support.v4.content.CursorLoader.loadInBackground(Unknown Source)
at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(Unknown Source)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(Unknown Source)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(Unknown Source)
at android.support.v4.content.ModernAsyncTask$2.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 4 more
答案 0 :(得分:0)
SQLiteException: near ":<phonenumber>": syntax error ... while compiling:
... WHERE search_index MATCH content:<phonenumber>* OR name:2024121E20201E14122412* ...
MATCH
适用于字符串。代码忘了在它们周围加上引号,如下所示:
... MATCH 'content:<phonenumber>* OR name:2024121E20201E14122412*' ...
这似乎是Android版联系内容提供商的一个错误。