Example usage for android.content ActivityNotFoundException getMessage

List of usage examples for android.content ActivityNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:it.rignanese.leo.slimfacebook.MessagesActivity.java

@Override
public void onExternalPageRequest(String url) {
    try {/*  www .  j  a  va  2  s. c o  m*/
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    } catch (ActivityNotFoundException e) {//this prevents the crash
        Log.e("shouldOverrideUrlLoad", "" + e.getMessage());
        e.printStackTrace();
    }
}

From source file:com.todoroo.astrid.files.FilesControlSet.java

private void showFromIntent(String file, String type) {
    try {//from   w w w .j av  a  2s .co  m
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(file)), type);
        activity.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        log.error(e.getMessage(), e);
        Toast.makeText(activity, R.string.file_type_unhandled, Toast.LENGTH_LONG).show();
    }
}

From source file:org.botlibre.sdk.activity.MicConfiguration.java

@TargetApi(23)
private void beginListening() {
    setStreamVolume();/*from  w w w  .ja v a 2 s  . com*/
    lastReply = System.currentTimeMillis();

    muteMicBeep(true);

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    if (MainActivity.offlineSpeech) {
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, MainActivity.voice.language);

        if (!this.failedOfflineLanguage) {
            //en-US will use the English in offline.
            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
            // intent.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true);
        }
        intent.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true);
    } else {
        if (MainActivity.voice.language != null && !MainActivity.voice.language.isEmpty()) {
            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, MainActivity.voice.language);
            if (!this.failedOfflineLanguage) {
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, MainActivity.voice.language);
            }
        } else {
            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en");
            if (!this.failedOfflineLanguage) {
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en");
            }
        }
    }

    try {
        Log.d("BeginListening", "StartListening");
        this.speech.startListening(intent);
        setMicIcon(true, false);
    } catch (ActivityNotFoundException a) {
        Log.d("BeginListening", "CatchError: " + a.getMessage());
        Toast t = Toast.makeText(getApplicationContext(), "Your device doesn't support Speech to Text",
                Toast.LENGTH_SHORT);
        t.show();
        txt.setText("Status: Your device doesn't support Speech to text.");
    }
}

From source file:de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.java

private void _open(String url, String contentType, String packageId, String activity,
        CallbackContext callbackContext, Bundle viewerOptions) throws JSONException {
    clearTempFiles();//from  w w  w. ja  v  a 2s  .  c om

    File file = getAccessibleFile(url);

    if (file != null && file.exists() && file.isFile()) {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            Uri path = Uri.fromFile(file);

            // @see http://stackoverflow.com/questions/2780102/open-another-application-from-your-own-intent
            intent.addCategory(Intent.CATEGORY_EMBED);
            intent.setDataAndType(path, contentType);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.putExtra(this.getClass().getName(), viewerOptions);
            //activity needs fully qualified name here
            intent.setComponent(new ComponentName(packageId, packageId + "." + activity));

            this.callbackContext = callbackContext;
            this.cordova.startActivityForResult(this, intent, REQUEST_CODE_OPEN);

            // send shown event
            JSONObject successObj = new JSONObject();
            successObj.put(Result.STATUS, PluginResult.Status.OK.ordinal());
            PluginResult result = new PluginResult(PluginResult.Status.OK, successObj);
            // need to keep callback for close event
            result.setKeepCallback(true);
            callbackContext.sendPluginResult(result);
        } catch (android.content.ActivityNotFoundException e) {
            JSONObject errorObj = new JSONObject();
            errorObj.put(Result.STATUS, PluginResult.Status.ERROR.ordinal());
            errorObj.put(Result.MESSAGE, "Activity not found: " + e.getMessage());
            callbackContext.error(errorObj);
        }
    } else {
        JSONObject errorObj = new JSONObject();
        errorObj.put(Result.STATUS, PluginResult.Status.ERROR.ordinal());
        errorObj.put(Result.MESSAGE, "File not found");
        callbackContext.error(errorObj);
    }
}

From source file:com.appnexus.opensdk.ANNativeAdResponse.java

boolean handleClick(String clickUrl, Context context) {
    if (clickUrl == null || clickUrl.isEmpty()) {
        return false;
    }//ww  w  .  j  av a  2  s.c o m
    // if install, open store
    if (clickUrl.contains("://play.google.com") || clickUrl.contains("market://")) {
        Clog.d(Clog.nativeLogTag, Clog.getString(R.string.opening_app_store));
        return openNativeIntent(clickUrl, context);
    }
    // open browser
    if (openNativeBrowser) {
        // if set to use native browser, open intent
        if (openNativeIntent(clickUrl, context)) {
            if (listener != null) {
                listener.onAdWillLeaveApplication();
            }
            return true;
        }
        return false;
    } else {
        // launch Browser Activity
        Class<?> activity_clz = AdActivity.getActivityClass();
        try {
            WebView out = new WebView(new MutableContextWrapper(context));
            WebviewUtil.setWebViewSettings(out);
            out.loadUrl(clickUrl);
            BrowserAdActivity.BROWSER_QUEUE.add(out);

            Intent intent = new Intent(context, activity_clz);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra(AdActivity.INTENT_KEY_ACTIVITY_TYPE, AdActivity.ACTIVITY_TYPE_BROWSER);
            context.startActivity(intent);
            return true;
        } catch (ActivityNotFoundException e) {
            Clog.w(Clog.baseLogTag, Clog.getString(R.string.adactivity_missing, activity_clz.getName()));
            BrowserAdActivity.BROWSER_QUEUE.remove();
        } catch (Exception e) {
            // Catches PackageManager$NameNotFoundException for webview
            Clog.e(Clog.baseLogTag, "Exception initializing the redirect webview: " + e.getMessage());
            return false;
        }

        return false;
    }
}

From source file:tkj.android.homecontrol.mythmote.MythMote.java

/**
 * Called when a menu item is selected/*from w ww  .j a v  a  2 s. co m*/
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    try {
        // Check which menu item was selected
        switch (item.getItemId()) {
        case SETTINGS_ID:
            // Create mythmote preferences intent and start the activity
            Intent settingsIntent = new Intent(this,
                    tkj.android.homecontrol.mythmote.MythMotePreferences.class);
            this.startActivity(settingsIntent);
            break;

        case RECONNECT_ID:
            MythCom mythCom = MythCom.GetMythCom(this);
            if (mythCom.IsConnected() || mythCom.IsConnecting())
                mythCom.Disconnect();

            // set selected location and connect
            if (this.setSelectedLocation())
                mythCom.Connect(sLocation);
            break;

        case SELECTLOCATION_ID:
            // Displays the list of configured frontend locations.
            // Fires the locationChanged event when the user selects a
            // location
            // even if the user selects the same location already selected.
            MythMotePreferences.SelectLocation(this, this);
            break;

        case SENDWOL_ID:
            WOLPowerManager.sendWOL(this, sLocation.MAC, 5);
            break;
        case DONATE_ID:
            this.startDonateIntent();
            break;

        case KEYBOARD_INPUT_ID:
            DialogFragment newFragment = new MythmoteKeyboardInputFragment();
            newFragment.show(getSupportFragmentManager(), "keyboard_input");
            break;

        }
        ;
    } catch (android.content.ActivityNotFoundException ex) {
        // Show error when activity is not found
        AlertDialog.Builder diag = new AlertDialog.Builder(this);
        diag.setMessage(ex.getMessage());
        diag.setTitle("Error");
        diag.setNeutralButton("OK", null);
        diag.show();
    }
    return false;
}

From source file:org.zywx.wbpalmstar.engine.universalex.EUExWidget.java

public void startApp(String[] params) {
    if (params.length < 2) {
        Log.e(tag, "startApp has error params!!!");
        return;//from ww  w  .  java 2  s . co m
    }
    String startMode = params[0];
    Intent intent = null;
    String extraJson = null;
    // ?NEW_TASK?Activity_by_waka
    boolean switchNewTask = true;// NEW_TASk?
    if (!TextUtils.isEmpty(startMode)) {
        if ("0".equals(startMode)) {
            String pkgName = params[1];
            String clsName = null;
            StartAppVO extraVO = null;
            if (params.length > 4) {
                extraVO = DataHelper.gson.fromJson(params[4], StartAppVO.class);
            }
            if (TextUtils.isEmpty(pkgName)) {
                Log.e(tag, "startApp has error params!!!");
                callBackPluginJs(JsConst.CALLBACK_START_APP, "error params");
                return;
            }

            if (params.length > 2) {
                clsName = params[2];
            }
            if (TextUtils.isEmpty(clsName)) {
                clsName = getMainActivity(pkgName);
            }
            if (TextUtils.isEmpty(clsName)) {
                Log.e(tag, "startApp has error params!!!");
                callBackPluginJs(JsConst.CALLBACK_START_APP, "package is not exist!");
                return;
            }
            ComponentName component = new ComponentName(pkgName, clsName);
            intent = new Intent();
            if (extraVO != null && extraVO.getData() != null) {
                Uri contentUrl = Uri.parse(extraVO.getData());
                intent.setData(contentUrl);
            }
            // isNewTask.equals("0") by waka
            if (extraVO != null && "0".equals(extraVO.getIsNewTask())) {
                switchNewTask = false;// NEW_TASKfalse
            }
            intent.setComponent(component);
        } else if ("1".equals(startMode)) {
            String action = params[1];
            String filterJson = null;
            intent = new Intent(action);
            if (params.length > 2) {
                filterJson = params[2];
            }
            if (!TextUtils.isEmpty(filterJson)) {
                intent = setIntentFilter(intent, filterJson);
            }
        } else {
            Log.e(tag, "startApp has error params!!!");
            callBackPluginJs(JsConst.CALLBACK_START_APP, "error params!");
            return;
        }
    }
    if (intent == null) {
        Log.e(tag, "startApp has error params!!!");
        callBackPluginJs(JsConst.CALLBACK_START_APP, "error params!");
        return;
    }
    if (params.length > 3) {
        extraJson = params[3];
        if (!TextUtils.isEmpty(extraJson)) {
            intent = setIntentExtras(intent, extraJson);
        }
    }
    try {
        // NEW_TASK
        if (switchNewTask) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);// NEW_TASK_FLAG
        }
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        callBackPluginJs(JsConst.CALLBACK_START_APP, e.getMessage());
    }
}

From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java

private void showLogFile(CommonLogFileListAdapter lfm_adapter, int pos) {
    Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.parse("file://" + lfm_adapter.getItem(pos).log_file_path), "text/plain");

    try {/*from w w  w  .  j a v a 2s.c  o m*/
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        CommonDialog mCommonDlg = new CommonDialog(getActivity(), getActivity().getSupportFragmentManager());
        mCommonDlg.showCommonDialog(false, "E",
                mContext.getString(R.string.msgs_log_file_browse_app_can_not_found), e.getMessage(), null);
    }
}

From source file:fi.mikuz.boarder.gui.internet.DownloadBoard.java

private void fillBoard(String favoriteText) {
    DownloadBoard.this.setTitle(mBoard.getUploaderUsername() + " - " + mBoard.getBoardName());

    TextView description = (TextView) findViewById(R.id.descriptionText);
    description.setText(mBoard.getDescription() + "\n\n");

    final TextView version = (TextView) findViewById(R.id.versionText);
    final String versionStr = "Version " + mBoard.getBoardVersion() + "\n";

    if (mBoard.getBoardVersion() > mBoard.getFavoriteBoardVersion() && mBoard.getFavoriteBoardVersion() != -1) {
        version.setText(versionStr + "Your version is " + mBoard.getFavoriteBoardVersion());
        final Button versionButton = (Button) findViewById(R.id.versionButton);
        versionButton.setVisibility(View.VISIBLE);
        versionButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                HashMap<String, String> sendList = new HashMap<String, String>();
                sendList.put(InternetMenu.USER_ID_KEY, mUserId);
                sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                sendList.put(InternetMenu.BOARD_ID_KEY, Integer.toString(mBoard.getBoardId()));
                new ConnectionManager(DownloadBoard.this, InternetMenu.mUpdateFavoriteBoardURL, sendList);

                version.setText(versionStr);
                versionButton.setVisibility(View.GONE);
            }/*from w ww  . j ava 2s . c om*/
        });
    } else {
        version.setText(versionStr);
    }

    Button comments = (Button) findViewById(R.id.comments);
    comments.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(DownloadBoard.this, DownloadBoardComments.class);
            XStream xstream = new XStream();
            i.putExtra(BOARD_KEY, xstream.toXML(mBoard));
            i.putExtra(DownloadBoardList.LOGGED_IN_KEY, mLoggedIn);

            if (mLoggedIn) {
                i.putExtra(InternetMenu.USER_ID_KEY, mUserId);
                i.putExtra(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
            }

            startActivity(i);
        }
    });

    mFavorite = (Button) findViewById(R.id.favorite);
    if (favoriteText != null) {
        mFavorite.setText(favoriteText);
    }
    mFavorite.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mLoggedIn) {
                HashMap<String, String> sendList = new HashMap<String, String>();
                sendList.put(InternetMenu.USER_ID_KEY, mUserId);
                sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                sendList.put(InternetMenu.BOARD_ID_KEY, Integer.toString(mBoard.getBoardId()));
                new ConnectionManager(DownloadBoard.this, InternetMenu.mFavoriteURL, sendList);
            } else {
                Toast.makeText(DownloadBoard.this, "Please login to favorite", Toast.LENGTH_LONG).show();
            }
        }
    });

    LinearLayout buttonLayout = (LinearLayout) findViewById(R.id.buttonLayout);
    for (final String boardUrl : mBoard.getUrlList()) {
        if (!boardUrl.equals("")) {
            Button boardUrlBtn = new Button(DownloadBoard.this);
            boardUrlBtn.setText(boardUrl);
            boardUrlBtn.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    try {
                        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(boardUrl));
                        startActivity(browserIntent);
                    } catch (ActivityNotFoundException e) {
                        Log.e(TAG, "Unable to open board url", e);
                        ACRA.getErrorReporter().handleException(e);
                    }
                }
            });
            buttonLayout.addView(boardUrlBtn);
        }
    }

    mScreenshot = (ImageView) findViewById(R.id.screenshot);

    try {
        URL screenshotUrl = new URL(mBoard.getScreenshot0Url());
        new DownloadScreenshot().execute(screenshotUrl);
    } catch (MalformedURLException e) {
        Log.e(TAG, "Error downloading screenshot " + e.getMessage());
        setProgressBarIndeterminateVisibility(false);
    }

    mThumbUpImage = (ImageView) findViewById(R.id.thumbUp);
    mThumbDownImage = (ImageView) findViewById(R.id.thumbDown);

    if (mLoggedIn) {

        HashMap<String, String> sendList = new HashMap<String, String>();
        sendList.put(InternetMenu.USER_ID_KEY, mUserId);
        sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
        sendList.put(InternetMenu.BOARD_ID_KEY, Integer.toString(mBoard.getBoardId()));
        new ConnectionManager(DownloadBoard.this, InternetMenu.mGetBoardThumbStatusURL, sendList);

        mThumbUpImage.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                HashMap<String, String> sendList = new HashMap<String, String>();
                sendList.put(InternetMenu.USER_ID_KEY, mUserId);
                sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                sendList.put(InternetMenu.BOARD_ID_KEY, Integer.toString(mBoard.getBoardId()));
                sendList.put(InternetMenu.RATE_GOOD_KEY, "1");
                new ConnectionManager(DownloadBoard.this, InternetMenu.mRateBoardURL, sendList);
            }
        });

        mThumbDownImage.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                HashMap<String, String> sendList = new HashMap<String, String>();
                sendList.put(InternetMenu.USER_ID_KEY, mUserId);
                sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                sendList.put(InternetMenu.BOARD_ID_KEY, Integer.toString(mBoard.getBoardId()));
                sendList.put(InternetMenu.RATE_GOOD_KEY, "0");
                new ConnectionManager(DownloadBoard.this, InternetMenu.mRateBoardURL, sendList);
            }
        });
    } else {
        mWaitDialog.dismiss();

        mThumbUpImage.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(DownloadBoard.this, "Please login to vote", Toast.LENGTH_LONG).show();
            }
        });

        mThumbDownImage.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(DownloadBoard.this, "Please login to vote", Toast.LENGTH_LONG).show();
            }
        });
    }
}

From source file:im.neon.activity.CommonActivityUtils.java

/**
 * Save a media in the downloads directory and offer to open it with a third party application.
 *
 * @param activity       the activity/*ww  w.jav  a2s  .c  om*/
 * @param savedMediaPath the media path
 * @param mimeType       the media mime type.
 */
public static void openMedia(final Activity activity, final String savedMediaPath, final String mimeType) {
    if ((null != activity) && (null != savedMediaPath)) {
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    File file = new File(savedMediaPath);
                    Intent intent = new Intent();
                    intent.setAction(android.content.Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.fromFile(file), mimeType);
                    activity.startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(activity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
                } catch (Exception e) {
                    Log.d(LOG_TAG, "## openMedia(): Exception Msg=" + e.getMessage());
                }
            }
        });
    }
}