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

  • Home
  • SEARCH
  • 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 6779897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:26:33+00:00 2026-05-26T16:26:33+00:00

I almost finished my appliaction … but now I can’t use the ContentResolver like

  • 0

I almost finished my appliaction … but now I can’t use the ContentResolver like this:

Bitmap imageBitmap = MediaStore.Images.Media.getBitmap(
            getContentResolver(), imageUri);   // Problem!!!!!   

I have no idea how to fix this…it works if i use this syntax in my main-Activity…
but it doesnt’t work in my class CustomItemizedOverlay.

I marked the line I have to fix …

eclipse says: the methode getContentResolver () is undefined for the type CustomItemizedOverlay

import java.util.ArrayList;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;
import android.app.Dialog;
import android.app.AlertDialog;
import android.widget.TextView;
import android.view.View;
import android.widget.ImageView;
import android.view.LayoutInflater;
import android.widget.Toast;
import android.view.ViewGroup;
import android.provider.MediaStore; 
import android.provider.MediaStore.Images;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.app.Application;
import android.content.ContentResolver;
import android.content.Context;




public class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem> {

   private ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>();
   private String title;
   private String id_string;
   private String type;
   private String name;
   private String adress;
   private String webpage;
   private String opening_hours;
   private Context context;
   private Uri imageUri;

   public CustomItemizedOverlay(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
   }

   public CustomItemizedOverlay(Drawable defaultMarker, Context context,String title,String id_string,String type,String name,String adress,String webpage,String opening_hours,Uri imageUri) {
        this(defaultMarker);
        this.context = context;
        this.title = title;
        this.id_string = id_string;
        this.type = type;
        this.name =name;
        this.adress = adress;
        this.webpage=webpage;
        this.opening_hours = opening_hours;
        this.imageUri = imageUri;

   }

   @Override
   protected OverlayItem createItem(int i) {
      return mapOverlays.get(i);
   }

   @Override
   public int size() {
      return mapOverlays.size();
   }

   @Override
   protected boolean onTap(int index) {
      OverlayItem item = mapOverlays.get(index);
      AlertDialog.Builder dialog = new AlertDialog.Builder(context);

      dialog.setTitle(title);
      View layout = View.inflate(context, R.layout.dialog, null);

      TextView id_text = (TextView)layout.findViewById(R.id.id);
      id_text.setText("id:"+id_string);
      TextView type_text = (TextView)layout.findViewById(R.id.type);
      type_text.setText("type:"+type);
      TextView name_text = (TextView)layout.findViewById(R.id.name);
      name_text.setText("name:"+name);
      TextView adress_text = (TextView)layout.findViewById(R.id.adress);
      adress_text.setText("adress:"+adress);
      TextView webpage_text = (TextView)layout.findViewById(R.id.webpage);
      webpage_text.setText("webpage:"+webpage);
      TextView opening_hours_text = (TextView)layout.findViewById(R.id.opening_hours);
      opening_hours_text.setText("opening_hours:"+opening_hours);


      ContentResolver con = new Contentresolver();

      ImageView imageView = (ImageView) layout.findViewById(R.id.photo);
      Bitmap imageBitmap = MediaStore.Images.Media.getBitmap(
                getContentResolver(), imageUri);   // Problem! HERE!!!!
      imageView.setImageBitmap(imageBitmap);


      dialog.setView(layout);
      dialog.show();
      return true;
   }

   public void addOverlay(OverlayItem overlay) {
      mapOverlays.add(overlay);
       this.populate();
   }

}

  • 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-26T16:26:33+00:00Added an answer on May 26, 2026 at 4:26 pm

    getContentResolver is a method that belongs to subclasses of Context, such as an Activity. your class does not have such a method so you can’t use it. Easiest fix is to store a reference to your activity in your new class:

    Context context;
    public CustomItemizedOverlay(Context myContext, Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
        context = myContext;
    }
    

    and then call context.getContentResolver(...) when you need it.

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

Sidebar

Related Questions

I'm almost finished with my program, but I have one problem that I can't
I almost finished the code, but still I need some help. This code calculates
I've almost finished my Data Mapper, but now I'm at the point where it
I am almost finished with this flash game, but when I test it the
i am almost finished with my first android game which i would like to
i am working on a recipe site (which is almost finished except this problem)
Almost every ios app now has something like Feed option. Programming that usually includes
I'm trying to learn Objective-C. I almost finished one excercise but it is not
I'm almost finished my first WP7 application and I'd like to publish it to
my flash-game is almost finished but there is a (big?) problem: At its current

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.