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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:41:01+00:00 2026-06-11T11:41:01+00:00

I am working with a SMS listener, code below: public class SMSReceiver extends BroadcastReceiver

  • 0

I am working with a SMS listener, code below:

public class SMSReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        EventEntry entry = ((MyApplication)context.getApplicationContext()).getCurrent();
        System.out.println("Received message: " + smsMessage[0].getMessageBody() + " - SILENCE IS " + ((entry != null) ? "ON" : "OFF"));
    }
}

And following modification to AndroidManifest

<application
    android:name="MyApplication" ...

In another part of my code (in a BroadcastReceiver for AlarmManager), I have

public void onReceive(Context context, Intent intent) {
    ((MyApplication).context.getApplicationContext()).setCurrent("TESTING");
}

However, when I run the application and send a sample text, I get the following debug messages:

09-15 15:07:30.974: I/System.out(21625): DEBUG!!!!!! Setting current event to TESTING
09-15 15:07:54.399: I/System.out(21605): DEBUG!!!!!! Getting current event: null

Any ideas why my application contexts are out of sync?

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-06-11T11:41:02+00:00Added an answer on June 11, 2026 at 11:41 am

    I can give you one alternative solution of this, Just you can override onCreate() method in your MyApplication class.

    class MyApplication extends Application {
    private static MyApplication singleTon;
    
    public MyApplication getInstance(){
    return singleTon;
    }
    
    @Override
    public void onCreate() {
    singleTon = this;
    }
    
    
    ...... Here your remaining code....
    
    }
    

    Now you can access the instance of this class and then call getApplicationContex();

     (MyApplication.getInstance().getapplicationContext()).getCurrent();
    

    Hope it can helpful to you…:)

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

Sidebar

Related Questions

I've got a working SMS receiver but when I try to load another class
I am working on a code which I need to send sms messages from
I'm interested in seeing working code for how to compose an SMS/MMS programmatically using
Iv'e been working with some code that will send a sms message and when
I am working in SMS message compose iPhone app. I want to design the
Im working on a program to send and recieve SMS using a GSM modem
I'm working on a project that relies on integrating with SMS/MMS messaging aggregator companies
I am working on an android app, where I need to save sender, SMS
I'm working on an SMS Application for Android, which undoubtedly needs to send SMSes
Possible Duplicate: Android SMS Receiver not working I am in the beginning stages of

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.