Example usage for android.content ActivityNotFoundException ActivityNotFoundException

List of usage examples for android.content ActivityNotFoundException ActivityNotFoundException

Introduction

In this page you can find the example usage for android.content ActivityNotFoundException ActivityNotFoundException.

Prototype

public ActivityNotFoundException(String name) 

Source Link

Usage

From source file:com.todoroo.astrid.voice.VoiceInputAssistant.java

public void showVoiceInputMarketSearch(DialogInterface.OnClickListener onFail) {
    String packageName;/*from ww  w.  ja  v  a  2s  .  c om*/
    if (AndroidUtilities.getSdkVersion() <= 7)
        packageName = "com.google.android.voicesearch.x";
    else
        packageName = "com.google.android.voicesearch";

    // User wants to install voice search, take them to the market
    Intent marketIntent = Constants.MARKET_STRATEGY.generateMarketLink(packageName);
    if (activity != null) {
        try {
            if (marketIntent == null)
                throw new ActivityNotFoundException("No market link supplied"); //$NON-NLS-1$
            activity.startActivity(marketIntent);
        } catch (ActivityNotFoundException ane) {
            DialogUtilities.okDialog(activity, activity.getString(R.string.EPr_marketUnavailable_dlg), onFail);
        }
    }
}

From source file:net.wequick.small.ApkBundleLauncher.java

@Override
public void prelaunchBundle(Bundle bundle) {
    super.prelaunchBundle(bundle);
    Intent intent = new Intent();
    bundle.setIntent(intent);/*from   w w  w .  j ava  2 s  . com*/

    // Intent extras - class
    String activityName = bundle.getActivityName();
    if (!ActivityLauncher.containsActivity(activityName)) {
        if (!sLoadedActivities.containsKey(activityName)) {
            if (activityName.endsWith("Activity")) {
                throw new ActivityNotFoundException(
                        "Unable to find explicit activity class " + "{ " + activityName + " }");
            }

            String tempActivityName = activityName + "Activity";
            if (!sLoadedActivities.containsKey(tempActivityName)) {
                throw new ActivityNotFoundException(
                        "Unable to find explicit activity class " + "{ " + activityName + "(Activity) }");
            }

            activityName = tempActivityName;
        }
    }
    intent.setComponent(new ComponentName(Small.getContext(), activityName));

    // Intent extras - params
    String query = bundle.getQuery();
    if (query != null) {
        intent.putExtra(Small.KEY_QUERY, '?' + query);
    }
}

From source file:org.kontalk.ui.AbstractComposeFragment.java

/** Starts an activity for picture attachment selection. */
@TargetApi(Build.VERSION_CODES.KITKAT)//from ww w .ja  v  a  2s.com
void selectGalleryAttachment() {
    boolean useSAF = MediaStorage.isStorageAccessFrameworkAvailable();
    Intent pictureIntent = createGalleryIntent(useSAF);

    try {
        startActivityForResult(pictureIntent, SELECT_ATTACHMENT_OPENABLE);
    } catch (ActivityNotFoundException e1) {
        try {
            if (useSAF) {
                // try direct file system access
                pictureIntent = createGalleryIntent(false);
                startActivityForResult(pictureIntent, SELECT_ATTACHMENT_OPENABLE);
            } else {
                // simulate error
                throw new ActivityNotFoundException("gallery");
            }
        } catch (ActivityNotFoundException e2) {
            Toast.makeText(getActivity(), R.string.chooser_error_no_gallery_app, Toast.LENGTH_LONG).show();
        }
    }
}