Android.Content.Activitynotfoundexception:

android.content.ActivityNotFoundException:

Maybe you need to check that you added the new activity to the manifest.xml file

Example:

<activity
android:name=".className"
android:label="@string/app_name" >
</activity>

android.content.ActivityNotFoundException: Unable to find explicit activity class Android Studio Kotlin Error

Replace:

R.layout.registration::class.java

with:

Registration::class.java

You are attempting to use a resource ID as an Activity class, and that will not work.

How to fix android.content.ActivityNotFoundException android-studio 2.3.3

The result when you scan a barcode is often not a valid URL. It is often just a string with several digits. It has no schema or protocol, so it is (very possibly) not defined "what type of resource locator it is". Android's ACTION_VIEW intent is mostly use this information to decide "start which app/activity to open this URL". With a lack of the important information, Android has no idea to open it.

You may specify some cases for handling the result. For example, if the result begins with "http://" or "https://", directly use your code to handle, but if it is just a string of numbers, display it directly, or append it after some string before it is used for Uri.parse, for example "https://google.com/search?q=", to search this barcode's value as you may wanted, or other things you want to do with that 13 digit result.

For example, (the code below written in mobile hasn't been tested, just show the idea):

@Override 
public void onClick(DialogInterface dialog, int which) {
Intent browserIntent;
if (myResult.startsWith("http://") || myResult.startsWith("https://"))
browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(myResult));
else
browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://google.com/search?q=" + myResult));
startActivity(browserIntent);
}

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);
}
}

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.



Related Topics



Leave a reply



Submit