参考了这个里面的代码
http://bbs.csdn.net/topics/380084274
一直报错
06-16 23:58:50.698 26148-26161/com.example.myapplication.app W/ContentResolver﹕ Failed to get type for: content://media/external/images/media/120818 (Unknown URL : content://media/external/images/media/120818)
06-16 23:58:50.708 26148-26161/com.example.myapplication.app W/Binder﹕ Caught a RuntimeException from the binder stub implementation.
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://media/external/images/media/120818 }
我自己的部分代码
@Override public void onMediaScannerConnected() { Log.d("onMediaScannerConnected", "success " + conn); Log.d("scanpath", "scanpath " + scanpath); conn.scanFile(scanpath, "image/png");//主要是这里原本和上面的那个链接是一样的写成了"image/*" 然后各种报错,报找不到activity,其实可能是对于的格式自动匹配有问题,应用装了快播,竟然默认打开了快播,无力吐槽。最后更正,高了一个晚上 }//媒体扫描 @Override public void onScanCompleted(String s, Uri uri) { try { Log.d("onScanCompleted", uri + "success" + conn); System.out.println("URI " + uri); System.out.println("path" + path); if (uri != null) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); Log.d("inten", "inten " + intent.toString()); startActivity(intent); } } finally { conn.disconnect(); conn = null; } }//媒体扫描完毕