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 4005014
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:20:35+00:00 2026-05-20T08:20:35+00:00

We currently have an application that sends out SMS to users, it acts like

  • 0

We currently have an application that sends out SMS to users, it acts like a SMS gateway sitting on an Android phone.

I have come across a lot of questions on how to reads SMS, SMS threads etc, i was wondering if it is possible to figure out which thread and incoming SMS belongs to.

We are looking at automating where we send an SMS to user with an ORDER ID, when user replies back we would like to figure out which thread the SMS belongs to and try to extract the ORDER ID from that SMS that initiated the conversation.

  • 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-05-20T08:20:35+00:00Added an answer on May 20, 2026 at 8:20 am

    You can find out the thread id with the code below. But it may be even better just to query all the messages with the same address and it is outbound (Sms.TYPE == 2 i think). This way you can bypass the need for the thread id, and just start looking for the Order ID in one swoop.

    import android.provider.Telephony.Sms;
    import android.provider.Telephony.Sms.Intents;
    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    import android.database.Cursor;
    import android.telephony.SmsMessage;
    
    public class SmsReceiver extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Intents.SMS_RECEIVED_ACTION)){
                int threadId = 0;
                SmsMessage[] messages = Intents.getMessagesFromIntent(intent);
    
                String fromAddress = messages[0].getDisplayOriginatingAddress();
    
                Cursor c = Sms.query(context.getContentResolver(), 
                                     new String[]{Sms.THREAD_ID}, 
                                     Sms.ADDRESS+"="+fromAddress, 
                                     Sms.DATE+" DESC");
                if(c.moveToNext()){
                    threadId = c.getInt(0);
                }
    
                c.close();
    
                if(threadId!=0){
                    //query the Sms again, reading body for your Order ID, etc ...
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a piece of code in my Android application that picks up
I have an application that runs on a headless linux box (a SheevaPlug, to
I have a website that needs to store two sets of user data into
I'm trying to write the most basic application for windows phone 7 and want
I'm currently developing a silverlight application with prism. From this application I need to
I am currently developing an application in C# using WPF. I need the program
I'm currently trying out Silverlight with RIA Services. I'm implementing a simple login form.
I'm trying to improve the automated testing in my application, but am unsure of
For one of our applications, I've written a utility that uses java's DOM parser.
Say I have an appengine app called foo at foo.appspot.com and my email i.e.

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.