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

  • Home
  • SEARCH
  • 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 8581159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:58:53+00:00 2026-06-11T20:58:53+00:00

I wrote application, that receive SMS. In the AndroidManifest.xml I wrote: <receiver android:name=.SmsReceiver> <intent-filter>

  • 0

I wrote application, that receive SMS.
In the AndroidManifest.xml I wrote:

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

All the SMS-es that are received are analyzed by the class SmsReceiver.

Class SmsReceiver:

public class SmsReceiver extends BroadcastReceiver
{
    private static final String SMS_RECEIVED = "com.example.remotecontrol.SMS_RECEIVED";
    private static final String SMS_CONTENT_KEY = "com.example.remotecontrol.SMS_CONTENT_KEY";

    @Override
    public void onReceive(Context context, Intent intent)
    {
        Bundle bundle = intent.getExtras();
        SmsMessage[] message = null;
        String contentMessage = "";
        if(bundle != null)
        {
            Object[] pdus = (Object[]) bundle.get("pdus");
            message = new SmsMessage[pdus.length];
            for(int i=0; i<message.length; i++)
            {
                message[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                contentMessage += "SMS from " + message[i].getOriginatingAddress() + ": ";
                contentMessage += message[i].getMessageBody() + "\n";
            }

            Toast.makeText(context, contentMessage, Toast.LENGTH_LONG).show();
        }

        Intent intentSmsReceived = new Intent();
        intentSmsReceived.setAction(SMS_RECEIVED);
        intentSmsReceived.putExtra(SMS_CONTENT_KEY, contentMessage);
        context.sendBroadcast(intentSmsReceived);

    }

}

It receive SMS and send intent to the program.

        registerReceiver(new BroadcastReceiver()
        {

            @Override
            public void onReceive(Context context, Intent intent)
            {
                String contentMessage = intent.getExtras().getString(SMS_CONTENT_KEY);
                Toast.makeText(context, contentMessage + "text", Toast.LENGTH_LONG).show();
                //TODO
                //process SMS

                unregisterReceiver(this);
            }

        }, new IntentFilter(SMS_RECEIVED));

This part of the code takes the intent and process SMS and interact with application.

How to unregister receiver written in Android Manifest? It process all SMS-es, I want it to process only one correct and the close.

  • 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-11T20:58:54+00:00Added an answer on June 11, 2026 at 8:58 pm

    If your broadcast receiver is specified in the manifest, it cannot be unregistered programmatically. You will need to take it out of the manifest and register it from within your code.

    alternatively you can leave it registered and add check at first line of onReceive . might be through a Boolean flag .

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

Sidebar

Related Questions

i wrote an application that listens received sms'. 2 problems occured. First , I
I wrote an application that re-hosts the Workflow 4 Designer (System.Activities.Presentation.WorkflowDesigner). Activities are discovered
I wrote an application that generates quiz applets. I could't find a portable way
I have wrote an application that syncs two folders together. The problem with the
I wrote a C# application that is a simple countdown timer. I use it
I have got a Wavecom Supreme GSM modem. I wrote a simple application that
I wrote an application in JAVA that adds articles to a Joomla site. My
(Using WPF) In a small application that I wrote, I am using some count-down
I have a process that currently runs in a Delphi application that I wrote
I keep getting the error in VS 2100 CRT detected that the application wrote

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.