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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:59:06+00:00 2026-06-18T04:59:06+00:00

Can somebody explain this to me please : Intent intent = new Intent(Context, AlarmReceiver.class);

  • 0

Can somebody explain this to me please :

Intent intent = new Intent(Context, AlarmReceiver.class);

I never understood and I seriously think I never will if somebody doesn’t try to explain this to me in depth. This whole context thing is so confusing to me. Sometimes it works like this :

Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);

Sometimes it wont work like that but it accepts only :

    Intent intent = new Intent(context, AlarmReceiver.class);

Sometimes its :

Intent intent = new Intent(this, AlarmReceiver.class);

etc. etc. and many other.

I understand basics of context but how many are there? And why does eclipse throw me an error once and another time its fine? Why do we need to declare context sometimes? :

Context context;

I’m unable to find the right context for all situations how do I know what is the right one in every situation?

  • 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-18T04:59:07+00:00Added an answer on June 18, 2026 at 4:59 am

    First of all, let me explain what the context is a bit better, then let’s go on to how it can be used and received. Essentially, context is a reference to linking your resources to your program. Each object is given its own context, which contains the resources required to set that object up. It is required for many objects to be created, and to get program identifying information, among other purposes. This makes it invaluable to set up new views and activities, but it can also be used for other purposes. See also this answer for more information.

    The context for an item can come from a variety of places. Sometimes it is stored and has to be retrieved, sometimes it is inherited. Basically, this is object oriented programming.

    Just to give you a few examples:

    Activity inherits context. Thus, if you are in an activity, you only need to pass itself to use the context. It also contains a pointer to getBaseContext(). You might occasionally need to reference that, if you need the entire application context, but most likely you won’t for a while.

    View does not inherit context. However, it does have a method getContext(). If you need to get a context from a view, this is the way to get it. This context will not be complete, but will only have the context for the contents of the View.

    Fragments also do not inherit context. They contain a method getActivity(), which if the Fragment is active, will return the activity, which is the context for the Fragment.

    BroadcastReceivers do not inherit context either. In fact, they do not contain context at all, but simply receive the current context when an event is received (Such as onReceive(Context context, Intent intent))

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

Sidebar

Related Questions

can somebody please explain my mistake, I have this class: class Account { private:
Can somebody explain me please why this is not working? XmlDocument xmlDoc = new
Can somebody please explain to me the meaning of this line of code? val
Can somebody please explain this IE7 bug to me? It occurs in Standards and
can somebody please explain what this program is doing? .= torg + 1000 main:
I've got: error a1 was not declared in this scope Can somebody please explain
Can somebody please explain what does this warning mean: undefined reference to 'WinMain@16' ?
Can somebody please explain this to me: I have a label and I want
Can somebody please explain how this works in jQuery. I tried to find some
Can somebody explain to me what this does in javascript? (function (x,y){}(x,y)); or this

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.