3

I am trying to open specific folder using gallery and have referenced to other similar questions open image form built_in gallery, and implements the following code, but still fails and reports error (shown in following logcat):

selectSpecificFolder:

private void selectSpecificFolder()
{
    File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyFolder");
    Log.d("File path ", dir.getPath());
    String dirPath=dir.getAbsolutePath();
    if(dir.exists() && dir.isDirectory()) {
        Intent intent = new Intent(Intent.ACTION_VIEW, null);
        intent.setType("image/*");
        intent.setData(Uri.fromFile(dir));

        Log.d("b4performSpecificCrop_startActivityForResult::", Integer.toString(3));
        startActivityForResult(intent, 3);
        Log.d("afterperformSpecificCrop_startActivityForResult::", Integer.toString(3));
    }
    else
    {
        Toast.makeText(this, "No file exist to show", Toast.LENGTH_LONG).show();
    }  
}

onActivityResult:

protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    super.onActivityResult(requestCode, resultCode, data);      
    if (requestCode == 3)
    {
        Log.d("INSIDE_ONACTIVITY_REQUEST3", Integer.toString(3));
        if (data==null) 
        {
            Toast.makeText(this,"No image selected",Toast.LENGTH_LONG).show();
        }
        else
        {
            Uri selectedImageUri = data.getData();
            String selectedImagePath = selectedImageUri.getPath();

            if(selectedImagePath!=null)
            {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setData(selectedImageUri);
                startActivity(intent);
            }
        }   
    }

Logcat:

03-02 23:56:09.910: D/b4performSpecificCrop_startActivityForResult::(18133): 3
03-02 23:56:09.940: D/Instrumentation(18133): checkStartActivityResult  :Intent { act=android.intent.action.VIEW dat=file:xxxxx }
03-02 23:56:09.940: D/Instrumentation(18133): checkStartActivityResult  inent is instance of inent:
03-02 23:56:09.950: D/AndroidRuntime(18133): Shutting down VM
03-02 23:56:09.950: W/dalvikvm(18133): threadid=1: thread exiting with uncaught exception (group=0x40c6e1f8)
03-02 23:56:09.965: E/AndroidRuntime(18133): FATAL EXCEPTION: main
03-02 23:56:09.965: E/AndroidRuntime(18133): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:xxxxx }
03-02 23:56:09.965: E/AndroidRuntime(18133):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1535)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1387)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at android.app.Activity.startActivityForResult(Activity.java:3195)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at com.abc.drawing.Doodlz.performSpecificCrop(Doodlz.java:1712)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at com.abc.drawing.Doodlz.access$20(Doodlz.java:1701)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at com.abc.drawing.Doodlz$43.onClick(Doodlz.java:1184)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at android.os.Looper.loop(Looper.java:137)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at android.app.ActivityThread.main(ActivityThread.java:4511)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at java.lang.reflect.Method.invokeNative(Native Method)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at java.lang.reflect.Method.invoke(Method.java:511)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
03-02 23:56:09.965: E/AndroidRuntime(18133):    at dalvik.system.NativeStart.main(Native Method)

Question:

In Logcat it reports android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:xxxxx } What does it means and how could this be solved? Thanks!!

PS: For the app, it does not have an individual layout that shows all the images in that specific folder. There is instead a "open folder" button such that when user has pressed the button. it would simply use the built-in gallery to show directly the image in the specific folder.

Community
  • 1
  • 1
pearmak
  • 4,979
  • 15
  • 64
  • 122

1 Answers1

0

I guess the problem is inside the AndroidManifest.xml

This is a main resource for this problem, check the Mark Murphy response: https://groups.google.com/forum/?fromgroups#!topic/android-beginners/nYFBeAgmkMU

This is a secondary, but basic the same problem Android: No Activity found to handle Intent error? How it will resolve

Community
  • 1
  • 1
mario ruiz
  • 880
  • 1
  • 11
  • 28