1

I'm trying to get a image to be shown using action view, and I keep getting a no activity found error. Here's what I'm using to save the file, followed by what I am using to try and show it

private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File

        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                    Uri.fromFile(photoFile));
            startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
        }
    }
}

Here's how I create the file for saving:

private File createImageFile() throws IOException {
    // Create an image file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = "JPEG_" + timeStamp + "_";
    File storageDir = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES);
    File image = File.createTempFile(
            imageFileName,  /* prefix */
            ".jpg",         /* suffix */
            storageDir      /* directory */
    );

    // Save a file: path for use with ACTION_VIEW intents
    mCurrentPhotoPath = "file:" + image.getAbsolutePath();
    return image;
}

Finally here's where the issues take place, upon trying to use a action view to open the image I get a "no activity found"

mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            MarkerOptions m;
            Intent intent;
            for(int x =0; x < mList.size(); x++){
                m = (MarkerOptions)mList.get(x);
                if(m.getPosition().equals(marker.getPosition())){
                   File f = (File)pList.get(x);
                   intent = new Intent();
                   intent.setAction(Intent.ACTION_VIEW);
                   intent.setDataAndType(Uri.parse(f.getAbsolutePath()), "image/");
                   startActivity(intent);
                   return false;
                }
            }
            return false;
        }
    });

Following here is the Logcat:

    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/file:/storage/emulated/0/Pictures/JPEG_20141201_113723_896105669.jpg typ=image/ }
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1765)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1485)
        at android.app.Activity.startActivityForResult(Activity.java:3736)
        at android.app.Activity.startActivityForResult(Activity.java:3697)
        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:840)
        at android.app.Activity.startActivity(Activity.java:4007)
        at android.app.Activity.startActivity(Activity.java:3975)
        at cedar.example.com.cedar.MapsActivity$2.onMarkerClick(MapsActivity.java:189)
        at com.google.android.gms.maps.GoogleMap$8.a(Unknown Source)
        at com.google.android.gms.maps.internal.k$a.onTransact(Unknown Source)
        at android.os.Binder.transact(Binder.java:380)
        at com.google.android.gms.maps.internal.bd.a(SourceFile:84)
        at com.google.maps.api.android.lib6.c.al.h(Unknown Source)
        at com.google.maps.api.android.lib6.gmm6.c.h.a(Unknown Source)
        at com.google.maps.api.android.lib6.gmm6.o.aw.a(Unknown Source)
        at com.google.maps.api.android.lib6.gmm6.o.bf.a(Unknown Source)
        at com.google.maps.api.android.lib6.gmm6.o.be.a(Unknown Source)
        at com.google.maps.api.android.lib6.gmm6.o.bu.d(Unknown Source)
        at com.google.maps.api.android.lib6.gmm6.o.ak.onSingleTapConfirmed(Unknown Source)
        at com.google.maps.api.android.lib6.gmm6.i.g.onSingleTapConfirmed(Unknown Source)
        at com.google.maps.api.android.lib6.gmm6.i.i.handleMessage(Unknown Source)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

This is my first time posting, I apologize if my formatting is inadequate or my question is silly. I've gone through multiple different answers on the site and none seemed to work

Ivan Gajic
  • 21
  • 1
  • 3

1 Answers1

1

Try this instead in your "public boolean onMarkerClick":

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/pdf/Read.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "image/");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
Giacomo De Bacco
  • 723
  • 6
  • 26