Refreshing Thumbnails (MICRO_KIND)?

All your problems with Audio, Video and Images.

Refreshing Thumbnails (MICRO_KIND)?

Postby Unicate » Tue Oct 25, 2011 1:26 pm

Hi everybody!

Is there a way to refresh the MICRO_KIND Thumbnails?

When I try this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package de.unicate.android.thumbnailtest;
  2.  
  3. import android.app.Activity;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.database.Cursor;
  9. import android.graphics.BitmapFactory;
  10. import android.net.Uri;
  11. import android.os.Bundle;
  12. import android.os.Environment;
  13. import android.provider.MediaStore;
  14. import android.view.View;
  15. import android.view.View.OnClickListener;
  16. import android.widget.Button;
  17. import android.widget.ImageView;
  18.  
  19. public class ThumbnailTestActivity extends Activity {
  20.    
  21.     private ImageView _image;
  22.     private long _id;
  23.     /** Called when the activity is first created. */
  24.     @Override
  25.     public void onCreate(Bundle savedInstanceState) {
  26.         super.onCreate(savedInstanceState);
  27.         setContentView(R.layout.main);
  28.        
  29.         _image = ((ImageView)findViewById(R.id.imageTest));
  30.        
  31.         _image.setOnClickListener(new OnClickListener() {
  32.            
  33.             @Override
  34.             public void onClick(View v) {
  35.                 _image.setImageBitmap(BitmapFactory.decodeFile("/mnt/sdcard/tmp/srgg.jpg"));
  36.                 _image.invalidate();
  37.             }
  38.         });
  39.        
  40.         _id = getIdByPath("/mnt/sdcard/tmp/srgg.jpg");
  41.        
  42.         ((Button)findViewById(R.id.buttonUpdate)).setOnClickListener(new OnClickListener() {
  43.            
  44.             @Override
  45.             public void onClick(View v) {
  46.                 // we want to receive if the mediascanner finished scanning the sdcard
  47.                 IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_FINISHED);
  48.                 // after the mediascanner finished scanning files
  49.                 intentFilter.addDataScheme("file");
  50.                 // registering the receiver
  51.                 registerReceiver(_receiver, intentFilter);
  52.                 //
  53.                 sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
  54.                
  55.             }
  56.         });
  57.        
  58.         showImage(_id);
  59.        
  60.     }
  61.    
  62.     public long getIdByPath(String path) {
  63.         String[] projection = { MediaStore.Images.ImageColumns._ID,
  64.                                 MediaStore.Images.ImageColumns.DATA
  65.                 };
  66.  
  67.         long id = -1;
  68.         Cursor cursor = getContentResolver().query(
  69.                 MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
  70.                 projection,
  71.                 MediaStore.Images.ImageColumns.DATA + " = ?",
  72.                 new String[]{path}, null);
  73.         if(null != cursor && cursor.getCount() > 0) {
  74.             if(cursor.moveToFirst()) {
  75.                 id = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.ImageColumns._ID));
  76.             }
  77.             cursor.close();
  78.         }
  79.         return id;
  80.     }
  81.    
  82.    
  83.     public void showImage(long id) {
  84.         if(id > 0) {
  85.                 _image.setImageBitmap(MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(),id ,MediaStore.Images.Thumbnails.MICRO_KIND,null));
  86.             _image.invalidate();
  87.         }
  88.     }
  89.     private BroadcastReceiver _receiver = new BroadcastReceiver() {
  90.         @Override
  91.         public void onReceive(Context context, Intent intent) {
  92.             showImage(_id);
  93.             unregisterReceiver(this);
  94.            
  95.         }
  96.        
  97.     };
  98. }  
  99.  
Parsed in 0.044 seconds, using GeSHi 1.0.8.4


... edit the image on the computer and start the app again. The thumbnail appears wrong after editing.

How do I refresh?
Unicate
Junior Developer
Junior Developer
 
Posts: 10
Joined: Thu Sep 02, 2010 8:23 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 10 guests