• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange in thumbnail image view from sdcard.

 
allen android
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
allen android wrote:


Please check your private messages for an important administrative matter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic