thumbnails - Android 2.2 GetThumbnail returns incorrect Bitmap -



thumbnails - Android 2.2 GetThumbnail returns incorrect Bitmap -

i'm using mediastore.video.thumbnails.getthumbnail() method fetch thumbnails files displaying in list. works begin with, after while thumbnails not ones match file. 1 time getthumbnail() starts failing seems homecoming same bitmap on , on again, regardless of file try. happens on htc desire, running android 2.2, , hard reproduce - start happening after time.

here (a cutting version of) source code:

static public bitmap getthumbnailforfile(file p_file, activity p_activity) { long imageid = getimageid(p_file, p_activity); if (imageid < 0) { homecoming null; } homecoming mediastore.images.thumbnails.getthumbnail(p_activity.getcontentresolver(), imageid, thumbnails.micro_kind, null); } public static long getimageid(file p_file, activity p_activity) { long result =-1; cursor c = p_activity.getcontentresolver().query(mediastore.images.media.external_content_uri, new string[]{mediastore.images.media._id +""}, mediastore.images.media.data +" '" + p_file.getabsolutepath(), null, null); c.movetonext(); if (!c.isafterlast()) { result = c.getlong(0); } c.close(); homecoming result; }

i'm doing same thing load video thumbnails. i've used debugging code inspect values returned getimageid(), , i'm pretty sure correct.

can see might doing wrong? or know reason why thumbnails stop beingness generated after time?

hmm, query has 'like' in it, , have 1 '. in add-on don't protect query against sql injection!

i recommend query this:

p_activity.getcontentresolver().query(mediastore.images.media.external_content_uri, new string[]{ mediastore.images.media._id +"" }, mediastore.images.media.data + "=?", new string[]{ p_file.getabsolutepath() }, null);

maybe problem.

android thumbnails mediastore

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -