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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:50:02+00:00 2026-06-11T01:50:02+00:00

So I guess I’m new to Android and confused about how android contextss work

  • 0

So I guess I’m new to Android and confused about how android contextss work and what is included in a context and what not. I was wondering if I imported a java file with a class that implements the View.OnClickListener in an activity does that count as part of the context or no? Also if I have a class named NewOnClick that implements View.OnClickListener can I use android:OnClick=”NewOnClick” or does that ONLY work with methods. The reason I ask is that I want to write my handlers that will be included in almost activity.

Also is there any way that someone can explain what a context exactly does a lot of these other ones don’t really explain what it is for or does just says that its passed to other widgets and manages resources, which really isn’t very descriptive at all in my opinion, if there is anyway that you can explain it to me in a way that someone who has worked with GTK (gtkmm) or wxWidgets makes sense.

  • 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-11T01:50:04+00:00Added an answer on June 11, 2026 at 1:50 am

    There is a simple way of looking at it, which is that Context is the base class for applications, Activities, services etc. Therefore, everything in an Activity inherits from Context. The Context in Android is the environment in which your currently executing code exists, meaning everything available to it and everything influencing it (at least, that you have access to).

    For example, within an Activity, “this” refers to the current Activity and, since this inherits from Context, accesses everything within the current context plus those things defined in the Activity, e.g. your local fields, additional methods etc.

    Take a look at the indirect subclasses here:

    http://developer.android.com/reference/android/content/Context.html

    NB. Never expose a context outside of the life cycle of the derived class. e.g. do not let any object with a life cycle greater than it’s container hang on to the reference.

    http://android-developers.blogspot.co.uk/2009/01/avoiding-memory-leaks.html

    Hope this helps, rather than confuses.

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

Sidebar

Related Questions

I guess this has been asked before here , but I'm still confused about
I guess the problem is that I do not know how to use factory
I guess my main question is, will this always work as long as I
I guess this is covered somewhere but I'm not able to find. Guess I'm
I guess I'm not clear on how to do and tests. I wanted to
I guess not as this is not working: <!DOCTYPE html> <html> <head> <meta charset=utf-8
I guess I have an easy question, I have not found the right answer
I guess I'm confused on how to display what I have made in another
I guess I'm not sending the data required by the API correctly. Any ideas
I guess this problem is really about performance, but I'm trying to get a

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.