aspose file tools*
The moose likes Android and the fly likes Strange in thumbnail image view from sdcard. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Strange in thumbnail image view from sdcard." Watch "Strange in thumbnail image view from sdcard." New topic
Author

Strange in thumbnail image view from sdcard.

allen android
Greenhorn

Joined: Aug 16, 2009
Posts: 1
Hi, all

I got strange in thumbnail image display.
When i want to show image in gridview, it always display no images in sdcard. But if i entry android build-in ap "Gallery" first (Use it show image first), and then re-enter into my ap, it can show gridview image normally.(It is just like scan image first, and show image later)
I got no clue about this, who can help me.

The code below:
String[] imageAttribs = new String[] {
MediaStore.Images.Thumbnails._ID,
MediaStore.Images.Thumbnails.DATA,
MediaStore.Images.Thumbnails.IMAGE_ID,
MediaStore.Images.Thumbnails.WIDTH,
};

Cursor imageCursor;
imageCursor = this.managedQuery(
MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
imageAttribs,
null,
null,
null);

if ((imageCursor !=null)&&(imageCursor.moveToFirst())) {

String thumbsID;
String thumbsImageID;
String thumbsData;
String thumbsWidth;

if(imageCursor.moveToFirst()){
Log.i(TAG, "[YES]imageCursor can move to first!");
}else{
Log.i(TAG, "[NO]imageCursor can not move to first!");
}

int thumbsIDCol = imageCursor.getColumnIndex(MediaStore.Images.Thumbnails._ID);
int thumbsDataCol = imageCursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA);
int thumbsImageIDCol = imageCursor.getColumnIndex(MediaStore.Images.Thumbnails.IMAGE_ID);
int thumbsWidthCol = imageCursor.getColumnIndex(MediaStore.Images.Thumbnails.WIDTH);
int num=0;

String dbgmsg = "thumbsIDCol = "+Integer.toString(thumbsIDCol)+"; thumbsDataCol = "+Integer.toString(thumbsDataCol)+"; thumbsImageIDCol = "+Integer.toString(thumbsImageIDCol)+"; thumbsWidthCol = "+Integer.toString(thumbsWidthCol);
Log.i(TAG, dbgmsg);

do {
// Get the field values
thumbsID = imageCursor.getString(thumbsIDCol);
thumbsData = imageCursor.getString(thumbsDataCol);
thumbsImageID = imageCursor.getString(thumbsImageIDCol);
thumbsWidth = imageCursor.getString(thumbsWidthCol);
Log.i("BMP","size "+ thumbsWidth+" "+thumbsID+" "+thumbsData+" "+thumbsImageID);
num++;
if(thumbsImageID!= null) {
ThumbsIDList.add(imageCursor.getString(thumbsImageIDCol));
ThumbsDataList.add(imageCursor.getString(thumbsDataCol));
//ThumbsDataList.add(imageCursor.getString(thumbsDataCol));
}
} while (imageCursor.moveToNext());
}else{
//Log.i(TAG, "******no image");
//showToast(this, "No Image In SDCard.");
//Toast.makeText(this, "No Image In SDCard.", 1000);
Toast.makeText(this, "No Image In SDCard.", Toast.LENGTH_SHORT).show();
setTitle("Picture Frame - [No Image In SDCard.]");
Button BTN = (Button)findViewById(R.id.sel_btn);
Button SBTN = (Button)findViewById(R.id.configure);
BTN.setEnabled(false);
SBTN.setEnabled(false);
}
return;
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9995
    
    7

allen android wrote:


Please check your private messages for an important administrative matter.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
 
subject: Strange in thumbnail image view from sdcard.
 
Similar Threads
Not Registering -4
GestureListener on gridview
How to add text to gridview
How to play audio using this code in Grid View
Get byte[] of image