android - number formats in sms table and contacts table -


the following code gives me count of 0 in toast when activity starts. dont understand since should give me 1 coz there sms in inbox corresponding contact, guess matter of phone number format between 2 tablesi.e sms table , contacts table. how sync phone numbers can able compare them. have tried phonenumberutils.format no avail. help: code:

package com.messagehider;  import java.util.arraylist; import java.util.date; import android.app.activity; import android.content.contentvalues; import android.content.intent; import android.content.sharedpreferences; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import android.net.uri; import android.os.bundle; import android.os.handler; import android.provider.contactscontract; import android.provider.contactscontract.commondatakinds.phone; import android.provider.contactscontract.contacts; import android.telephony.phonenumberutils; import android.view.view; import android.view.view.onclicklistener; import android.widget.adapterview; import android.widget.adapterview.onitemclicklistener; import android.widget.arrayadapter; import android.widget.button; import android.widget.listview; import android.widget.simplecursoradapter; import android.widget.textview; import android.widget.toast;  public class contactsmses extends activity implements onitemclicklistener,onclicklistener{     textview textviewsource;     listview listviewcontactsms;     button buttonhide;     simplecursoradapter adapter;     handler handler=new handler();     uri smsuri=uri.parse("content://sms/inbox");     uri contenturi=contactscontract.contacts.content_uri;     uri phoneuri=contactscontract.commondatakinds.phone.content_uri;     cursor cursor=null,cursor2=null,cursor3=null,cursor_sms=null;     arraylist<string>names= new arraylist<string>();     arrayadapter<string> array_adapter;     string sender;     @override     protected void oncreate(bundle savedinstancestate) {         setcontentview(r.layout.contactsmses);         listviewcontactsms=(listview)findviewbyid(r.id.listviewcontactsms);         textviewsource=(textview)findviewbyid(r.id.textviewsmssource);         buttonhide=(button)findviewbyid(r.id.buttonhide);         buttonhide.setonclicklistener(this);         listviewcontactsms.setonitemclicklistener(this);         super.oncreate(savedinstancestate);     }     @override     protected void onstart() {         intent intent=getintent();         sender=intent.getstringextra("sender");         textviewsource.settext("messages "+sender+":");         sharedpreferences prefs=getsharedpreferences(sms.preference_file,0);         string sms_sender=prefs.getstring("smssender","no such sender");         cursor2=getcontentresolver().query(contenturi, null, contacts.display_name+"=?",new string[]{sms_sender},null);         cursor2.movetofirst();         string contact_id=cursor2.getstring(cursor2.getcolumnindex(contacts._id));         cursor3=getcontentresolver().query(phoneuri, null, phone.contact_id+"=?", new string[]{contact_id}, null);         cursor3.movetofirst();         string number=cursor3.getstring(cursor3.getcolumnindex(phone.number));         cursor_sms=getcontentresolver().query(smsuri, null, "address=?", new string[]{number}, null);         cursor_sms.movetofirst();         toast.maketext(getapplicationcontext(), string.valueof(cursor_sms.getcount()), toast.length_long).show();         /*string[]from={"body"};         int[]to={android.r.id.text1};         adapter=new simplecursoradapter(getapplicationcontext(),android.r.layout.simple_list_item_multiple_choice, cursor_sms, from, to);         listviewcontactsms.setadapter(adapter);         listviewcontactsms.setchoicemode(listview.choice_mode_multiple);*/         super.onstart();     } 


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -