user2511968
user2511968

Reputation:

Activity Not FOund Exception While Opening File android

I'm getting this exception

06-28 21:00:48.792: W/System.err(10272): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/01 - 3G - Kaise Bataaoon [SongsPK.info] (2).mp3 typ=audio/mpeg }

I'm trying to open this file via these code :

    File sdCard = Environment.getExternalStorageDirectory();

                            Intent intnt = new Intent(Intent.ACTION_VIEW);

                            String ext = fileToOpen.substring(fileToOpen.lastIndexOf('.')+1) ;
                            //Intent j = Intent.createChooser(intnt, "Choose an application to open with:");
                            //startActivity(j);
                            File fl = new File(sdCard.getAbsolutePath()+"/"+ fileToOpen);
                            if(fl.exists())
                            {
                                Log.d("FILEMANAGERACTIVITY",fl.getPath() + "0"+ ext);
                                MimeTypeMap mim = MimeTypeMap.getSingleton();
                                String type= mim.getMimeTypeFromExtension(ext);
                                intnt.setDataAndType(Uri.fromFile(fl) , type);
                                startActivity(intnt);
                            }

Upvotes: 0

Views: 877

Answers (2)

H4F
H4F

Reputation: 131

add the activty to mainfist.xml may help you

Upvotes: 1

Martin Cazares
Martin Cazares

Reputation: 13705

Make sure the data and type you are sending in intnt.setDataAndType(Uri.fromFile(fl) , type); is correct, seems like the Intent.ACTION_VIEW do not have any match for that intent data and hence there's no activity to handle that intent...

Regards!

Upvotes: 3

Related Questions