2013-05-03 15 views
6

Hi chcę otworzyć zdjęcie w galerii, poniżej jest mój kodjak otworzyć bitmapę w galerii w Android

mImageView.setImageBitmap(AppUtil.getBitmapFromFile(obj.getImageUrl(), 200, 200)); 

    mImageView.setOnClickListener(new OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      Intent intent = new Intent(); 
      intent.setAction(Intent.ACTION_VIEW); 
      intent.setDataAndType(Uri.parse(obj.getImageUrl()), "image/*"); 
      startActivity(intent); 
     } 
    }); 

ale jego pokazując NullPointerException

Uri.parse(obj.getImageUrl() returns below string 

/mnt/sdcard/Zdjęcia/app_images /pro20130429_170323_-1793725321.tmp

zmiana: teraz próbowałem
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("file://sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp"))); i otrzymuję błąd że

05-03 16:40:18.460: E/AndroidRuntime(4764): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file://sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp } 
+0

możliwy duplikat [Otwórz obraz przy użyciu URI w galerii obraz domyślny viwer Android] (http://stackoverflow.com/questions/ 5383797/open-an-image-using-uri-in-androids-default-gallery-image-viwer) –

Odpowiedz

4

próbować ten jeden

Intent intent = new Intent(); 
intent.setAction(Intent.ACTION_VIEW); 
intent.setDataAndType(Uri.parse("file://" + "/sdcard/Pictures/app_images/pro20130429_170323_-1793725321.tmp"), "image/*"); 
startActivity(intent); 
+0

tak, działa, ale pokazuje obraz po pewnym czasie – Raja

Powiązane problemy