Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8551215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:08:54+00:00 2026-06-11T14:08:54+00:00

I am working on an android sms application.I can send sms to single contact

  • 0

I am working on an android sms application.I can send sms to single contact by using the following code.

sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);

Now I want to send sms to multicontacts.Some suggest to use loop.SO now I am using loops to send sms to multicontact.

After sending each sms I write those values to sent table.

 ContentValues values = new ContentValues();
    values.put("address", mobNo);
    values.put("body", msg);
    getContentResolver().insert(Uri.parse("content://sms/sent"), values); 

Every new address will create a new thread id.
For example if my receiver’s address is x, then thread id 1, for y thread id 2.And if I want to send sms to both x and y ,then how can I write in to sms/sent table.
If I use Loop,then it won’t create any new thread id, because send address x already have thread id 1 and y already have thread id 2.So messages will listed under thread id 1 and 2 never creates a new thread id.

I tried to manualy insert thread id by

values.put("thread_id", 33);

But then the messages under new thread id do not listed in default app but in my app.

Please help me friends

Edit:I tried using 0, and then reading the thread_id that was generated, then place the next sms with this thread_id, still doesn’t works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:08:55+00:00Added an answer on June 11, 2026 at 2:08 pm

    You need to create a new thread_id manually, a normal contentResolver.insert(...) won’t do for multiple recipient messages. To create the new thread_id you query the following uri

    content://mms-sms/threadID

    and to it append the necessary recipients so that finally it looks like this

    content://mms-sms/threadID?recipient=9808&recipient=8808

    So the full example would look like this. Say the recipients are 9808 and 8808

    Uri threadIdUri = Uri.parse('content://mms-sms/threadID');
    Uri.Builder builder = threadIdUri.buildUpon();
    String[] recipients = {"9808","8808"};
    for(String recipient : recipients){
        builder.appendQueryParameter("recipient", recipient);
    }
    Uri uri = builder.build();
    

    Now you can query uri in the normal way and this will give you a thread_id that you can use for the recipients specified, it will create a new id if one doesn’t exist or return an existing one.

    Long threadId = 0;
    Cursor cursor = getContentResolver().query(uri, new String[]{"_id"}, null, null, null);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                threadId = cursor.getLong(0);
                }
        } finally {
                cursor.close();
        }
    }
    

    Now use threadId to insert your SMSs.

    A few things to note.

    Do not use this threadId to insert single recipient messages for either 9908 or 8808, create a new thread_id for each or just do an insert without specifying the thread_id.

    Also, be very careful with the builder.appendQueryParameter(...) part, make sure the key is recipient and not recipients, if you use recipients it will still work but you will always get the same thread_id and all your SMSs will end up in one thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an SMS Application for Android, which undoubtedly needs to send SMSes
I am working on an android sms application.I have to send sms to multiple
I am working on an android application and I want to send an SMS
I am working on android chat application. I am facing a problem in send
I am working on a android application which read the sms from content provider.
Hi I am working Android application development using titanium studio.I have developed small application.my
I need a help in Android sms application. I am sending a message from
I am working on sms application in android in which user have to input
Hi working on an Android SMS application in scala alls going fine expect I
I am working on an Android sms application. I have a problem with sending

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.