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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:57:04+00:00 2026-06-01T05:57:04+00:00

i have a question regarding an gallery/picture tag app im making for a course.

  • 0

i have a question regarding an gallery/picture tag app im making for a course.

My application is a gallery/tag pic app. It starts by displaying a gridview that display the thumbnails of all the phones pictures stored on SD card.
The problem im experiencing is after this course of action:
Gridview -> user clicks on a pic -> Fullview of picture -> user clicks back -> return to gridview
so after having returned to the gridview, when scrolling around, the blocks of thumbnails that is not in direct view gets removed, However the objects are still there and clickable but the thumbnail is not visible.

hope to get some help with this 😀

public class App2Activity extends Activity {
/** Called when the activity is first created. */
static Cursor cursor;
static int columnIndex;
static Bitmap bMap;
static String imagePath;
protected static ContentResolver cr;
@Override

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

    String[] projection = {MediaStore.Images.Thumbnails._ID}; //Columns to return
    cursor = managedQuery(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.Thumbnails.IMAGE_ID);//Puts selected columns in cursor object
    columnIndex = cursor.getColumnIndex(MediaStore.Images.Thumbnails._ID);//return columns index


    GridView imagesview = (GridView) findViewById(R.id.gridView1);
    imagesview.setAdapter(new ImageAdapter(this));
    //Method litsens for thumbnail that is clicked and then loads the full image bit map
    imagesview.setOnItemClickListener(new OnItemClickListener(){
        public void onItemClick(AdapterView<?> parent, View v, int position, long id){
            String[] projection = {MediaStore.Images.Media.DATA};
            //This segment fetches selected image path
            cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
            columnIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
            cursor.moveToPosition(position);
            imagePath = cursor.getString(columnIndex);


            Intent intent = new Intent(v.getContext(), Fullview.class);

            FileInputStream in;
            BufferedInputStream buf;

            try {
                in = new FileInputStream(imagePath);
                buf = new BufferedInputStream(in);
                bMap = BitmapFactory.decodeStream(buf);
                startActivity(intent);//Start fullviewclass to project bitmap in fullscreen

                if (in != null) {
                    in.close();
                }
                if (buf != null) {
                    buf.close();
                }
            } catch (Exception e) {
                Log.e("Error reading file", e.toString());
            }

        }
    });

}
//Inflates menu when button is pressed
public boolean onCreateOptionsMenu(Menu menu){

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.exitmenu, menu);

    return true;
    }
//handles the exit menu button
public boolean onOptionsItemSelected(MenuItem item){

    switch(item.getItemId()){
        case R.id.exit:
        finish();
        default:
            return super.onOptionsItemSelected(item);
    }
}

}

class ImageAdapter extends BaseAdapter{
private Context context;

public ImageAdapter(Context cont){
    context = cont;
}
@Override
public int getCount() {

    return App2Activity.cursor.getCount();
}

@Override
public Object getItem(int position) {
    return position;
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ImageView iv;
    // this segment sets up the gridview
    if(convertView == null){
        iv = new ImageView(context);

        iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
        iv.setPadding(4, 4, 4, 4);
        iv.setLayoutParams(new GridView.LayoutParams(120, 120));
    }

    else {
        iv = (ImageView)convertView;
    }
    //fetches thumbnails
    App2Activity.cursor.moveToPosition(position);
    int imageID = App2Activity.cursor.getInt(App2Activity.columnIndex);
    iv.setImageURI(Uri.withAppendedPath(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, "" + imageID));
    return iv;
}

}

public class Fullview extends Activity {


public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fullview);
    ImageView iv = (ImageView)findViewById(R.id.imageView1);
    iv.setImageBitmap(App2Activity.bMap);

}
//Inflates menu when button is pressed
public boolean onCreateOptionsMenu(Menu menu){

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);

    return true;
 }
//Handles menu options
public boolean onOptionsItemSelected(MenuItem item){

    switch(item.getItemId()){
        case R.id.back:
        finish();
        case R.id.Tag:

            Intent intent = new Intent(getApplicationContext(), ContactsDisplay.class);
            startActivityForResult(intent, 0);
            return true;

        case R.id.tagged:
            Intent intent2 = new Intent(getApplicationContext(), TaggedViewer.class);
            startActivity(intent2);
            return true;

        default:
            return super.onOptionsItemSelected(item);
    }
}

//Gets the result Uri from choosing a contact after having pressed menu option "Tag" and saves pic/contact combination to internal storage
protected void onActivityResult(int requestCode, int resultCode, Intent data){
    if(resultCode == RESULT_OK){
        if(requestCode == 0){   
            //This segment saves the tagged contact uri and hashes the associated imagepath name which become filename internal storage file
            Uri result = data.getData();
            String toBeStored = result.toString();
            Log.w("GOT", result.toString());

            int filehash = App2Activity.imagePath.hashCode();
            String strfilehash = String.valueOf(filehash);

            try {
                FileOutputStream fos = openFileOutput(strfilehash, MODE_PRIVATE);
                fos.write(toBeStored.getBytes());
                fos.close();
            } catch (FileNotFoundException e) {
                Log.w("FileWrite", "FileError");
            } catch (IOException e) {
                Log.w("FileWrite", "WriteError");
            }
        }
    }

Before bug picture
so this is what the view looks like before the bug occurs. All pics are there, and then after returning from fullview and some scrolling later, the bug occur and view looks like the one below. Note: it keeps all pictures that have been visible the whole time, and also the objects whom thumbnail disappeared, they are still clickable.
After bug picture

Logcat says this when trying to fetch back one of the images that is supposed to return to the view:

Unable to open content: content://media/external/images/thumbnails/0
java.io.FileNotFoundException: No entry for content://media/external/images/thumbnails/0
and then some additional stuff and finally:
resolveUri fialed on bad bitmap uri: content://media/external/images/thumbnails/0

So somehow the image adapter class cant find any thumbnails for the pictures that is supposed to return to the current view.
i would’ve included an image of this entire logcat entry but im currently not allowed to post more than 2 links 🙂

Hope that is all information you need 🙂
will be happy for any help i can get!

  • 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-01T05:57:06+00:00Added an answer on June 1, 2026 at 5:57 am

    I found the problem on my own. The problem lied in that i used the same variables for getting thumbnails and then for getting fullview pics, so when i went back to the gallery screen, the thumbnail query had gotten the wrong tables. In essence, it tried to fetch thumbnails from the table of the full pictures.

    Lession learned, reusing global variables for no reason = bad 😀

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

Sidebar

Related Questions

I have a question regarding the threads that my application spawns during execution and
I have a question regarding in-app billing. I have a published app that currently
I have a question regarding jQuery. I have multiple images that are, in essence,
I have a question regarding class design. I want to have a class that
I have a question regarding uitable view. I am implementing an app which is
I have a question regarding string modification. Let's assume that we have the following
I have a question regarding parsing data from Wikipedia for my Android app. I
I have a question regarding some JavaScript, there is a big picture and the
I have question regarding associations in Ruby on Rails. In the application there are
I would have question regarding web services. Let's say I have webservice client that

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.