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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:47:42+00:00 2026-06-17T13:47:42+00:00

I’ve seen on SO that @Commonsware states that all that is needed to receive

  • 0

I’ve seen on SO that @Commonsware states that all that is needed to receive SMS’s is a Broadcast Receiver (i.e., without the use of a service). I’d like to employ that approach since it makes sense to me. Unfortunately it does not appear as if SMS’s are being received/processed in my Broadcast Receiver. The apk is being installed successfully but no log entries are being generated when I send test SMS’s. What am I doing wrong?

Here’s the Manifest:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.oheller.pete2"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon_broadcastreceiver"
        android:label="@string/sms_broadcastreceiver"
        android:theme="@style/Theme.eagleeyeactionbar" >

        <receiver android:name=".SMSReceiver_Test" >
            <intent-filter android:priority="999">
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>

        <provider
            android:name=".contentprovider.GPSTrackerContentProvider"
            android:authorities="net.oheller.pete2.contentprovider"
            android:grantUriPermissions="true"
            android:multiprocess="true"
            android:permission="true" >
        </provider>
    </application>

</manifest>

Here’s the SMS Receiver code. It’s purpose is to collect data via SMS’s and write a record of each to the content provider (SQLite database).

public class SMSReceiver_Test extends BroadcastReceiver { 
TelephonyManager telephonyManager;
String deviceCountryCode = "";

@Override
public void onReceive(Context context, Intent intent) {
    //Get the SMS message passed in from the intent
    Bundle SMSmessageContent = intent.getExtras();
    SmsMessage[] receivedSMS = null;
    String returnStr = "";
    Long current_time_stamp = Calendar.getInstance().getTimeInMillis();
    String curTimeString = getFormattedDate(current_time_stamp, "dd-MMM-yy h:mma");     

    telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);       

    String incoming_SMSphone_number = "";
    String SMSmsgText = "";
    long timeStamp = current_time_stamp;

    if (SMSmessageContent != null) {  // [IF valid SMS]
        //Retrieve the SMS message info
        Object[] pdus = (Object[]) SMSmessageContent.get("pdus");
        receivedSMS = new SmsMessage[pdus.length];
        for (int i=0; i<receivedSMS.length; i++) {  // [FOR get SMS content]
            receivedSMS[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
            incoming_SMSphone_number = receivedSMS[i].getOriginatingAddress().toString().trim();
            SMSmsgText = receivedSMS[i].getMessageBody().toString();
            returnStr += curTimeString +"\n";

Log.d("EagleEye", String.format("SMSReciever: SMS=\"%s\"", SMSmsgText))  ;  ///DEBUG
        }  // [ENDFOR get SMS content]

            ///////////////////////////
            // prepare values for insertion into the SQLite DB
                ContentValues GPSTrackValues = new ContentValues();
                GPSTrackValues.put(GPSTrackerTable.COLUMN_PHONE_NUMBER, incoming_SMSphone_number);
                GPSTrackValues.put(GPSTrackerTable.COLUMN_TIME_STAMP, timeStamp);

 //// Prepare access to content provider
                Uri GPSuri = GPSTrackerContentProvider.CONTENT_URI_GPS_Tracks; //specify the content provider location
                ContentResolver GPSTrackCR = context.getContentResolver();          

                // Insert new entry into DB
                Uri insertURI = GPSTrackCR.insert(GPSuri, GPSTrackValues);      
Log.d("EagleEye", "DB insert results="+insertURI)  ;  ////////DEBUG

    }  // [ENDIF Valid SMS] 
}  // [END onReceive]
   }  // [END SMSReceiver]
  • 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-17T13:47:43+00:00Added an answer on June 17, 2026 at 1:47 pm

    Code seems to me correct.
    You can try by increasing the priority by max ..

     <intent-filter android:priority="2147483647">
    

    There may be case , when other receiver is getting sms before yours and aborting them.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am confused How to use looping for Json response Array in another Array.
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a small JavaScript validation script that validates inputs based on Regex. I

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.