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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:41:36+00:00 2026-05-26T15:41:36+00:00

I paste some piece of my code here: public void onCreate(Bundle savedInstanceState) { Log.e(Main

  • 0

I paste some piece of my code here:

public void onCreate(Bundle savedInstanceState) {
        Log.e("Main Activity", "OnCreate");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_frame);

        //GlowEffect is the custom class's constructor:GlowEffect(context);
        new GlowEffect2(getApplictionContext());

        AlertDialog.Builder builder = new Builder(this);
...
...

I find that when I change the param in **Builder(this)** to Builder(getApplicationContext());
The app will crash! While the GlowEffect2 constructor works well whatever the param is “this” or "getApplicationContext()".
So what the difference between the two params?

  • 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-05-26T15:41:37+00:00Added an answer on May 26, 2026 at 3:41 pm

    As you’ve noticed, the constructor for Builder takes a Context object as argument.

    The Activity and Application objects are both subclasses of Context, so either would be a valid parameter to create a Builder.

    Object -> Context -> ContextWrapper -> Application
    Object -> Context -> ContextWrapper -> ContextThemeWrapper -> Activity

    What’s the difference between an Application and an Activity? I think one of the most obvious differences is their life cycles:

    • The Activity will live for as long as that particular piece of UI is running, and will be destroyed and recreated in various situations, e.g. on an orientation change, or when the Activity is not being viewed and the Android OS needs to free some memory by destroying Activities that are not being viewed.

    • The Application will live for as long as the application itself is running.

    As for your specific problem, what is the stack trace for the crash? This question says getApplicationContext() might be null because the application is still starting up whilst the Activity is being created (the answer says the issue was fixed in Android OS 1.6).

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

Sidebar

Related Questions

I'm working with a legacy piece of code in some stuff for work which
The following piece of code gets a page via curl , extracts some strings
I am having trouble with the most simple piece of code. For some reason,
I need to paste some Google Analytics code into my WordPress site. It's the
I've noticed that some sites (usually banks) suppress the ability to paste text into
i have DX treeList, it has some functionality like copy, paste, delete and so
Hi can anyone past some code how to do a restful web service get
I have inherited some code from a guy whose favorite past time was to
In the past I had quite some reusable code in my project which I
Using Ajax.ActionLink's OnSuccess-Event brings me some trouble. As asked here the function cannot be

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.