I need to get list of text messages and display them like in stock aplication or Go sms pro. I'm using following code:
uriSms = Uri.parse("content://mms-sms/conversations");
Cursor cursor = getContentResolver().query(uriSms, new String[] {"*"}, null, null, "date DESC");
cursor.moveToFirst();
do{
try{
String address = cursor.getString(32);
if(address == null){
address = ""; //phone number
}else{
address = getContactName(address);
}
String body = cursor.getString(2);
System.out.println("======> Mobile number => "+address);
System.out.println("=====> SMS Text => "+body);
}catch (Exception e) {
e.printStackTrace();
}
}while(cursor.moveToNext());
It works on my galaxy tab ( android 2.2 ) but on my s3 (ICS) application crashes at start. I don't want to parse mms so i tried using
uriSms = Uri.parse("content://sms/conversations");
but it didn't work on both devices. I googled a lot to find a solution and I found nothing. I have only discovered that access to sms conversations depends on android os and device. My purpose is to make application which support every android device 2.2+. In stock application they using Thread.CONTENT_URI to get sms list as conversations eg.
Threads.CONTENT_URI.buildUpon().appendQueryParameter("simple", "true").build();
but class Thread isn't provided with source code and I can't find it in internet. What can I do to make my application run on every android device (2.2+) just like Handcent Sms or GO sms pro.