Send SMS that can be viewed in other Messengers? [SOLVED]

Put your problem here if it does not fit any of the other categories.

Send SMS that can be viewed in other Messengers? [SOLVED]

Postby DMacATTACK » Wed Nov 10, 2010 12:44 am

Hi all,
When I send an SMS using the SMS manager (examples found all over the net), the SMS is successful, with and without using Pending Intents. So my question is; why aren't the sent messages visible in the default and 3rd party messengers (such as Handcent?). This has to be possible, after all the messages sent from applications such as Handcent can be viewed in the default messenger.

Much thanks.
Last edited by DMacATTACK on Thu Nov 11, 2010 1:59 am, edited 1 time in total.
User avatar
DMacATTACK
Experienced Developer
Experienced Developer
 
Posts: 58
Joined: Thu Dec 31, 2009 6:31 pm
Location: Canada

Top

Re: Send SMS that can be viewed in other Messengers?

Postby Emilm » Wed Nov 10, 2010 1:17 pm

Guess you need to store your message with the content provider, so other apps can access your message.

Try to store your message with contents like this:

ContentValues values = new ContentValues();
values.put("address", "123456789");
values.put("body", "Hey");
getContentResolver().insert(Uri.parse("content://sms/inbox), values);
Emilm
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sun Nov 07, 2010 3:42 pm
Location: Trondheim, Norway

Re: Send SMS that can be viewed in other Messengers?

Postby DMacATTACK » Wed Nov 10, 2010 1:42 pm

Yeah I actually was thinking that too, and was trying to look up info on that, BUT there seems to be no documentation for SMS content provider? The best I can figure is its content://sms/sent but again its NOT documented so I cannot find what the fields are.
Thanks
User avatar
DMacATTACK
Experienced Developer
Experienced Developer
 
Posts: 58
Joined: Thu Dec 31, 2009 6:31 pm
Location: Canada

Re: Send SMS that can be viewed in other Messengers?

Postby Emilm » Wed Nov 10, 2010 2:05 pm

I know, I had some of the same problems in my app when i was trying to delete incoming messages. Made it work, but got Exceptions some times. So i guess its not a good solution. But since messages sent with Hancent is visible in the native sms application i guess It`s possible.
Emilm
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sun Nov 07, 2010 3:42 pm
Location: Trondheim, Norway

Re: Send SMS that can be viewed in other Messengers? [SOLVED

Postby DMacATTACK » Thu Nov 11, 2010 2:08 am

So even though the content provider for Sent Messages and Inbox messages isn't documented, I did find out the necessary info by using the wonderful functions of a cursor. The code below can be used to retrieve the column data in order to be able to insert your own rows. Once your row is inserted, other messenger applications can read it.

I must also say that while searching I did find that this content provider is undocumented, but it is also not necessarily supported, and should not but used. However Handcent (> 250,000 downloads) clearly uses such a provider.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                         Uri messageUri = Uri.parse("content://sms/sent");
  2.                        
  3.                         Cursor messageCursor = getContentResolver().query(messageUri, null, null, null, null);
  4.                        
  5.                         // show the column names of the sent sms'
  6.                         for (int i=0; i<messageCursor.getColumnCount() ; i++)
  7.                         {
  8.                         Log.d("Test", "column(" + i + ") = " + messageCursor.getColumnName(i));
  9.                         }
  10.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


This code will output:

column(0) = _id
column(1) = thread_id
column(2) = address
column(3) = person
column(4) = date
column(5) = protocol
column(6) = read
column(7) = status
column(8) = type
column(9) = reply_path_present
column(10) = subject
column(11) = body
column(12) = service_center
User avatar
DMacATTACK
Experienced Developer
Experienced Developer
 
Posts: 58
Joined: Thu Dec 31, 2009 6:31 pm
Location: Canada

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 18 guests