View image in ACTION_VIEW intent?

前端 未结 2 605
谎友^
谎友^ 2020-12-08 16:55

I\'d like to show a png or jpg I downloaded from the next in an image viewer intent, but can\'t get it to work.

Bitmap bmp = getImageBitmap(jpg);
String path         


        
相关标签:
2条回答
  • 2020-12-08 17:27

    Check out Android issue 2092 it sounds similar to what you are describing. The issue states, "Bitmap.compress() fails for PNG files saved in Indexed Color Mode (instead of RGB color mode)", however the first commenter thinks that, "it looks like its not an indexed color problem but a PNG problem."

    It looks like your code is fine, compare it to this Android snippet:

    Intent intent = new Intent();  
    intent.setAction(android.content.Intent.ACTION_VIEW);  
    File file = new File("/sdcard/test.mp4");  
    intent.setDataAndType(Uri.fromFile(file), "video/*");  
    startActivity(intent);   
    
    Intent intent = new Intent();  
    intent.setAction(android.content.Intent.ACTION_VIEW);  
    File file = new File("/sdcard/test.mp3");  
    intent.setDataAndType(Uri.fromFile(file), "audio/*");  
    startActivity(intent); 
    
    0 讨论(0)
  • 2020-12-08 17:52

    Another problem may be permissions on the file. Typically your /data/data/[app]/ directories are not world readable, and are owned by you applications "app_XX" user/group. Either make sure your permissions are correct, or make sure the file is in a place that both applications can read (emms, or sd card)

    0 讨论(0)
提交回复
热议问题