Android 没有 Activity 找到处理 Intent MediaScanner

Android no Activity Found to Handle Intent MediaScanner

我正在尝试使用特定文件夹中的 Images/Videos 打开图库。我正在使用 this solution 但我收到以下错误代码,但没有任何反应。我猜这是关于 Uri 的问题,但我找不到解决方案。有没有人知道如何解决这个问题?我还包含了 "my" 代码。

03-15 16:30:53.733 21902-22775/de.comidos.fotoapp D/onScanCompleted: Scan completed: content://media/external/images/media/1730
03-15 16:30:53.752 21902-22775/de.comidos.fotoapp D/Instrumentation: checkStartActivityResult() : Intent { act=android.intent.action.VIEW dat=content://media/external/images/media/1730 launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
03-15 16:30:53.773 21902-22775/de.comidos.fotoapp W/Binder: Binder call failed.
                                                            android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://media/external/images/media/1730 launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
                                                                at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1839)
                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1531)
                                                                at android.app.Activity.startActivityForResult(Activity.java:4389)
                                                                at android.app.Activity.startActivityForResult(Activity.java:4348)
                                                                at android.app.Activity.startActivity(Activity.java:4672)
                                                                at android.app.Activity.startActivity(Activity.java:4640)
                                                                at de.comidos.fotoapp.GalleryViewActivity.onScanCompleted(GalleryViewActivity.java:59)
                                                                at android.media.MediaScannerConnection.scanCompleted(MediaScannerConnection.java:55)
                                                                at android.media.IMediaScannerListener$Stub.onTransact(IMediaScannerListener.java:60)
                                                                at android.os.Binder.execTransact(Binder.java:573)

package de.comidos.fotoapp;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import java.io.File;


public class GalleryViewActivity extends Activity implements MediaScannerConnection.MediaScannerConnectionClient {
    public String[] allFiles;
    private String SCAN_PATH ;
    private static final String FILE_TYPE = "*/*";

    private MediaScannerConnection conn;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gallery);

        File folder = new File(Environment.getExternalStorageDirectory().toString()+"/comidos/sent/");
        allFiles = folder.list();
        //   uriAllFiles= new Uri[allFiles.length];
        for(int i=0;i<allFiles.length;i++)
        {
            Log.d("all file path"+i, allFiles[i]+allFiles.length);
        }
        //  Uri uri= Uri.fromFile(new File(Environment.getExternalStorageDirectory().toString()+"/yourfoldername/"+allFiles[0]));
        SCAN_PATH= Environment.getExternalStorageDirectory().toString()+"/comidos/sent/"+allFiles[0];
        Log.d("SCAN PATH", "Scan Path " + SCAN_PATH);

    }
    private void startScan()
    {
        Log.d("Connected","success"+conn);
        if(conn!=null)
        {
            conn.disconnect();
        }
        conn = new MediaScannerConnection(this,this);
        conn.connect();
    }
    @Override
    public void onMediaScannerConnected() {
        Log.d("onMediaScannerConnected","success"+conn);
        conn.scanFile(SCAN_PATH, FILE_TYPE);
    }
    @Override
    public void onScanCompleted(String path, Uri uri) {
        try {
            Log.d("onScanCompleted","Scan completed: "+uri );
            if (uri != null)
            {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(uri);
                startActivity(intent);
            }
        } finally
        {
            conn.disconnect();
            conn = null;
        }
    }
    @Override
    public void onResume(){
        super.onResume();
        startScan();

    }
}

您的设备上没有 activity 支持 ACTION_VIEWcontent Uri 的任何 MIME 类型的内容。 Android 设备不需要为每个可能的内容片段提供 ACTION_VIEW activity。