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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:14:04+00:00 2026-06-17T14:14:04+00:00

When I install the app everything works fine. I am able to print Message

  • 0

When I install the app everything works fine. I am able to print Message body every time I send a message until I lock mobile screen. After that, the app stops printing incoming messages. I tried many ways to overcome this problem but with no luck. Please help me…

public class SmsReceiveActivity extends Activity{

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sms);

receiver = new BroadcastReceiver() {

@Override
public void onReceive(Context context, Intent intent) {

if (intent.getAction().equals(SMS_RECEIVED)) {
Object[] pdus = (Object[]) bundle.get("pdus");
final android.telephony.SmsMessage[] messages = new android.telephony.SmsMessage[pdus.length];

for (int i = 0; i < pdus.length; i++) {
    messages[i] = android.telephony.SmsMessage.createFromPdu((byte[]) pdus[i]);
    incomingMsgString += messages[i].getMessageBody().toString();
   }
    // Print Incoming message Body
  }
 }
}        
  getApplication().registerReceiver(receiver, new IntentFilter(SMS_RECEIVED));
 }
}
  • 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-17T14:14:05+00:00Added an answer on June 17, 2026 at 2:14 pm

    Per the BroadcastReceiver docs, when you register a receiver with registerReceiver(), “You won’t receive intents when paused”. If you want a receiver that is independent of your activity, you should implement it as a named class and publish it in your manifest. For example, create a named class with your anonymous BroadcastReceiver,

    public class MyReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
    
    if (intent.getAction().equals(SMS_RECEIVED)) {
    Object[] pdus = (Object[]) bundle.get("pdus");
    final android.telephony.SmsMessage[] messages = new android.telephony.SmsMessage[pdus.length];
    
    for (int i = 0; i < pdus.length; i++) {
        messages[i] = android.telephony.SmsMessage.createFromPdu((byte[]) pdus[i]);
        incomingMsgString += messages[i].getMessageBody().toString();
       }
        // Print Incoming message Body
      }
     }
    } 
    

    And in your manifest add the receiver inside your application tag

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

    Then when an SMS message is received your onReceive method will be invoked. There you can package up the information you need and launch an intent to your Activity or Service for further processing.

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

Sidebar

Related Questions

I'm creating an app using Google calendar API. Everything works fine on my local
I'm trying to use FB Connect on my app, and everything works fine in
We developed an offline HTML5 web-app using the .manifest caching mechanism. Everything works as
I am using inno setup to install a vb6 application and drivers. Everything works
My gnuplot scripts use awk to preprocess some data. Everything works fine in Linux.
As a general rule, everything works fine, but then sometimes either Eclipse or my
We have a Blackberry app that is installed by users OTA. The install works
I am developing an iOS (5.0+) app, which works very fine on 6 different
How do I install the app that I'm making on an actual device? I'm
I'm trying to install my app from the Mac App Store now that it's

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.