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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:33:55+00:00 2026-05-28T19:33:55+00:00

Possible Duplicate: Android SMS Receiver not working I am in the beginning stages of

  • 0

Possible Duplicate:
Android SMS Receiver not working

I am in the beginning stages of a simple app to intercept sms messages from a specific number. At this point, all I’m trying to achieve is a toast when the onReceive method is fired, however I’m not getting anything.

manifest

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.*****"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <uses-sdk android:minSdkVersion="8" />

   <application android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <receiver android:name=".Receiver">
            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED"/>
            </intent-filter>
        </receiver>
    </application>
</manifest>

And the receiver

public class Receiver extends BroadcastReceiver {

    private static final String SENDER = "****";
    private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";

     @Override
     public void onReceive(Context context, Intent intent) {    
         Toast.makeText(context, "Received!", Toast.LENGTH_LONG).show();

         if (intent.getAction().equals(SMS_RECEIVED)) {
             Bundle bundle = intent.getExtras();
             if (bundle != null) {
                 Object[] pdus = (Object[])bundle.get("pdus");
                 final SmsMessage[] messages = new SmsMessage[pdus.length];
                 for (int i = 0; i < pdus.length; i++) {
                     messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
                 }
                 if (messages.length > -1) {
                     Toast.makeText(context, "Received a message!", Toast.LENGTH_LONG).show();
                     //abortBroadcast();
                 }
             }
         }
    }


}

Update 1
After creating an activity and launching the app, the receiver is registered. I need a way to have the receiver registered automatically though. There is no activity for the app, just the onReceive method intercepting the message. Is this possible? Perhaps using the boot complete intent?

UPdate 2
Solved it using a receiver for BOOT_COMPLETED to start a service which registered the sms receiver. Thanks.

  • 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-28T19:33:56+00:00Added an answer on May 28, 2026 at 7:33 pm

    Your solution is flawed. It will work for Android 3.0 and older. For Android 3.1, you must have an activity that the user launches at least once, to enable your app.

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

Sidebar

Related Questions

Possible Duplicate: How to restrict Android device to not open some specific site e.g.youtube,
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Android Launch an application from another application I want to start Another
Possible Duplicate: Why does Android app run in small window on tablet emulator? i
Possible Duplicate: slow android emulator My tablet is not here yet, which is why
Possible Duplicate: Android NoSuchAlgorithmException: SSLContext SSL implementation not found Has anybody experience with this
Possible Duplicate: Eclipse Android SDK slow Content Assist performance For reasons not worth discussing
Possible Duplicate: Dynamic Resource Loading Android In Android, I can load a string from
Possible Duplicate: Android: How to stop media (mp3) in playing when specific milliseconds come?
Possible Duplicate: Android: How to get values in under specific xml tags Hi guys,

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.