No Activity Found to Handle Intent:Android.Intent.Action.View

No Activity found to handle Intent (android.intent.action.VIEW)

The probem was that the OP was using an incorrect mime-type as the parameter. Android does not support all types of mimes but this can be checked by using MimeTypeMap.

Return the MIME type for the given extension if supported, null otherwise.

final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension("pdf");

No Activity found to handle Intent error with valid url

You are using implicit intents to open a web link. It's possible that a user won't have any apps that handle the implicit intent you send to startActivity(). Or, an app may be inaccessible because of profile restrictions or settings put into place by an administrator. If that happens, the call fails and your app crashes. To verify that activity will receive the intent, call resolveActivity() on your Intent object. If the result is non-null, there is at least one app that can handle the intent and it's safe to call startActivity(). If the result is null, do not use the intent and, if possible, you should disable the feature that issues the intent. The following example shows how to verify that the intent resolves to an activity. This example doesn't use a URI, but the intent's data type is declared to specify the content carried by the extras.

// Create the text message with a string
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType("text/plain");

// Verify that the intent will resolve to an activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(sendIntent);
}

Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent

I create a method which based on @andreban's answer. I believe it will open url %99.99 times.

public static void openURL(Context mContext, Uri uri) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setShowTitle(true);
CustomTabsIntent customTabsIntent = builder.build();
Intent browserIntent = new Intent()
.setAction(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setType("text/plain")
.setData(Uri.fromParts("http", "", null));

List<ResolveInfo> possibleBrowsers;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
possibleBrowsers = mContext.getPackageManager().queryIntentActivities(browserIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (possibleBrowsers.size() == 0) {
possibleBrowsers = mContext.getPackageManager().queryIntentActivities(browserIntent, PackageManager.MATCH_ALL);
}
} else {
possibleBrowsers = mContext.getPackageManager().queryIntentActivities(browserIntent, PackageManager.MATCH_DEFAULT_ONLY);
}

if (possibleBrowsers.size() > 0) {
customTabsIntent.intent.setPackage(possibleBrowsers.get(0).activityInfo.packageName);
customTabsIntent.launchUrl(mContext, uri);
} else {
Intent browserIntent2 = new Intent(Intent.ACTION_VIEW, uri);
mContext.startActivity(browserIntent2);
}
}

No Activity found to handle Intent

You are running this code on an Android environment that lacks the Google Play Store, such as an emulator, Kindle Fire, etc.

If you are encountering this on an emulator, test this code path on a device that has the Play Store.

If you are encountering this on some piece of hardware that lacks the Play Store, or if you are planning on distributing your app to devices that lack the Play Store, either handle the exception or use PackageManager and resolveActivity() to determine if your Intent will succeed before calling startActivity().

if(intent.resolveActivity(getPackageManager()) != null)
startActivityForResult(intent, 0);
else
...

No Activity found to handle Intent { act=android.intent.action.CALL dat=tel0710000001 }

try add this in your manifest.xml :

<uses-permission android:name="android.permission.CALL_PHONE" />

But, in the Reference, this permission is classified who "Protection level: dangerous", I recommend use this:

Kotlin:

  val i = Intent(Intent.ACTION_DIAL)
i.data = Uri.parse("tel:$phone")
startActivity(i)

Java:

 Intent i =new Intent(Intent.ACTION_CALL);
i.setData(Uri("tel:"+phone));
startActivity(i);

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=zhanysch@gmail.com }

Your intent for opening Gmail is wrong. I recommend looking into "Send email intent" in Android.

But for the simple case, change this:

val client = Intent(Intent.ACTION_VIEW , Uri.parse("zhanysch@gmail.com"))

into this:

val client = Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:zhanysch@gmail.com"))

For a better, more generic solution, I recommend checking the official docs.

Android : No Activity found to handle Intent Error

You can Avoid App crash when there's no Activity to handle an Intent by surrounding your Intent with a Try-Catch, Catching ActivityNotFoundException and have it do something else when there's no activity to open the intent instead of crashing the app:

          if (url.contains("youtu")) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
mContext.startActivity(intent);
} catch (ActivityNotFoundException e){
//Then Do something here
//Maybe a Toast to tell User they don't have an Activity that
//can
//open that intent or open it via Browser
}
}

This way, You keep your app from crashing and you retain your users. Also, you handle a scenario where there's no activity to open an Intent



Related Topics



Leave a reply



Submit