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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:33:15+00:00 2026-06-08T10:33:15+00:00

Possible Duplicate: Static Way to get Context on android? I have a broadcast receiver

  • 0

Possible Duplicate:
Static Way to get Context on android?

I have a broadcast receiver class and service class and I am starting my service inside my broadcast receiver if I receive a string “testing”.

THis is how I start my service inside my broadcast receiver class. It’s working

private void startSMSforwarderService(Context context,String y)
{
    if(y.startsWith("testing"))
    {
        Intent SmsForwarderService = new Intent(context,SmsForwarderService.class);
        SmsForwarderService.putExtra("var_msgbody",msgbody); //pass variable value via intent from broadcast receiver to android service
        SmsForwarderService.putExtra("var_from", from);

        context.startService(SmsForwarderService);
    }
}

I have a method inside my service that needs context and I want to extend my context from my broadcast receiver to my service. How could I do that? Some snippet would much appreciated.. Thanks

my receiver
https://gist.github.com/3171877

My service class

https://gist.github.com/3171792

As you can see I have a method inside my service and it needs a context before I can use that..

void forwardSMS(String msgbody,Context smsSenderService, Intent SENT_ACTION)

Basically I want to pass my broadcast receiver context to my service class….

  • 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-08T10:33:17+00:00Added an answer on June 8, 2026 at 10:33 am

    Problem solved.. I found this Static way to get 'Context' on Android?

    but is their another way to do it?

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

Sidebar

Related Questions

Possible Duplicate: Static Way to get Context on android? Not sure if the answer
Possible Duplicate: How can a static class derive from an object? I have a
Possible Duplicate: From the string name of a class, can I get a static
Possible Duplicate: Are static members inherited? (C++) If I have a parent class (
Possible Duplicate: Returning in a static initializer Is there a way to exit a
Possible Duplicate: C++ static virtual members? Can we have a static virtual functions? If
Possible Duplicate: Do static members of a class occupy memory if no object of
Possible Duplicate: Cannot declare Public static final String s = new String(“123”) inside an
Possible Duplicate: Android SMS Receiver not working I am in the beginning stages of
Possible Duplicate: Referring to a static member of a subclass Please have a look

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.