No Activity found to handle Intent : android.intent.action.VIEW

Solution 1:

Url addresses must be preceded by http://

Uri uri = Uri.parse("www.google.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);

throws an ActivityNotFoundException. If you prepend "http://", problem solved.

Uri uri = Uri.parse("http://www.google.com");

Solution 2:

If you are also getting this error when trying to open a web page from your android app it is because your url looks like this:

www.google.com

instead of: https://www.google.com or http://www.google.com

add this code to your Activity/Fragment:

 public void openWebPage(String url) {

    Uri webpage = Uri.parse(url);

    if (!url.startsWith("http://") && !url.startsWith("https://")) {
        webpage = Uri.parse("http://" + url);
    }

    Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

just pass your url to openWebPage(). If it is already prefixed with https:// or http:// then you are good to go, else the if statement handles that for you

Solution 3:

This is the right way to do it.

    try
    {
    Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW);
    File file = new File(aFile.getAbsolutePath()); 
    String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString());
    String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
    myIntent.setDataAndType(Uri.fromFile(file),mimetype);
    startActivity(myIntent);
    }
    catch (Exception e) 
    {
        // TODO: handle exception
        String data = e.getMessage();
    }

you need to import import android.webkit.MimeTypeMap;

Solution 4:

For me when trying to open a link :

Uri uri = Uri.parse("https://www.facebook.com/abc/");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);

I got the same error android.content.ActivityNotFoundException: No Activity found to handle Intent

The problem was because i didnt have any app that can open URLs (i.e. browsers) installed in my phone. So after Installing a browser the problem was solved.

*Lesson : Make sure there is at least one app which handles the intent you are calling *

Solution 5:

Answer by Maragues made me check out logcat output. Appears that the path you pass to Uri needs to be prefixed with
file:/

Since it is a local path to your storage.

You may want too look at the path itself too.

`05-04 16:37:37.597: WARN/System.err(4065): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=/mnt/sdcard/mnt/sdcard/audio-android.3gp typ=audio/mp3 }`

Mount point seems to appear twice in the full path.