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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:15:29+00:00 2026-05-27T23:15:29+00:00

Literally all I have done is create a new project. import android.app.Activity; import android.content.ContentResolver;

  • 0

Literally all I have done is create a new project.
import android.app.Activity;
import android.content.ContentResolver;
import android.os.Bundle;
public class WebApp4Act extends Activity {
/** Called when the activity is first created. */
public static final Uri BOOKMARKS_URI =
Uri.parse(“content://browser/bookmarks”);
Context context = getBaseContext();
ContentResolver cr = getContentResolver();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main); 
}
}

when I run the project it says unfortunately webApp4c has stopped

if I comment out the line
ContentResolver cr = getContentResolver();
then there is no problem
I’m trying to run this on an AVD set to run on version 14

  • 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-27T23:15:30+00:00Added an answer on May 27, 2026 at 11:15 pm

    That answer is quite simple. Unfortunately, getContentResolver() and any other methods that require a Context cannot do so during the Application Construction process or Initialization. On some versions of the AVD, this was not properly replicated, so that’s why it works on some versions of the AVD. All you have to do is move your code to inside onCreate() (or any other function that runs AFTER construction) and you will be fine.

    Note: There ARE ways to pass a custom View or Activity this information during construction, but there are two caveats:

    1. You cannot do so for the first Component launched in your Application without another Application or Application Component giving it to you…
    2. This CAN lead to unsafe code.

    In most circumstances, it is just best to work within the Android Lifecycle. If you need some information on the Android Lifecycle, you may get it from the Android documentation or from the Javadoc.

    Additional Note (Edit): You don’t actually need the getBaseContext() up there. There are several kinds of Context and your Activity counts as one. getBaseContext() is best used for when you need to pass or hold a Context outside of the Android Lifecycle.

    Hope this helps,
    FuzzicalLogic

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

Sidebar

Related Questions

I have been at this literally all day. I can create linked lists no
Hey all. I've got a new app up and running on a new ubuntu
Is it just me or literally ALL the examples that I have seen on
If you have binary strings (literally String objects that contain only 1's and 0's),
I have a string which follows literally : lt;img src=quot;http://www.news.gov.tt/thumbnail.php?file=Hon__Jerry_Narace_Minister__Of_Health_599152837.jpgamp;size=summary_mediumquot;gt;lt;pgt;Fifty-eight people have been tested
In my career I have seen literally dozens of ways that people choose to
I'm working on my first iPhone app and have been able to get most
I could have sworn i have done this somewhere - im using 2.0 right
I have this problem. Specific website, I have visited literally thousands of pages in
What have you done to remove (Helpers/extension methods) string literal in code? e.g. I

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.