Example usage for android.content ActivityNotFoundException printStackTrace

List of usage examples for android.content ActivityNotFoundException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:freed.ActivityAbstract.java

@Override
public void ChooseSDCard(I_OnActivityResultCallback callback) {
    try {//from  www .  j  ava 2 s .co m
        resultCallback = callback;
        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
        startActivityForResult(intent, READ_REQUEST_CODE);
    } catch (ActivityNotFoundException activityNotFoundException) {
        activityNotFoundException.printStackTrace();
    }
}

From source file:ml.puredark.hviewer.ui.fragments.SettingFragment.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getPreferenceManager().setSharedPreferencesName(SharedPreferencesUtil.FILE_NAME);
    addPreferencesFromResource(R.xml.preferences);

    String downloadPath = DownloadManager.getDownloadPath();
    if (downloadPath != null) {
        String displayPath = Uri.decode(downloadPath);
        getPreferenceManager().findPreference(KEY_PREF_DOWNLOAD_PATH).setSummary(displayPath);
    }//from  w w  w  .  j a  va2 s .  co  m
    ListPreference listPreference = (ListPreference) getPreferenceManager()
            .findPreference(KEY_PREF_VIEW_DIRECTION);
    CharSequence[] entries = listPreference.getEntries();
    int i = listPreference.findIndexOfValue(listPreference.getValue());
    i = (i <= 0) ? 0 : i;
    listPreference.setSummary(entries[i]);
    listPreference.setOnPreferenceChangeListener(this);
    listPreference = (ListPreference) getPreferenceManager().findPreference(KEY_PREF_VIEW_VIDEO_PLAYER);
    entries = listPreference.getEntries();
    i = listPreference.findIndexOfValue(listPreference.getValue());
    i = (i <= 0) ? 0 : i;
    listPreference.setSummary(entries[i]);
    listPreference.setOnPreferenceChangeListener(this);

    getPreferenceScreen().setOnPreferenceChangeListener(this);
    final DirectoryChooserConfig config = DirectoryChooserConfig.builder()
            .initialDirectory((downloadPath.startsWith("/")) ? downloadPath : DownloadManager.DEFAULT_PATH)
            .newDirectoryName("download").allowNewDirectoryNameModification(true).build();
    mDialog = DirectoryChooserFragment.newInstance(config);
    mDialog.setTargetFragment(this, 0);

    float size = (float) Fresco.getImagePipelineFactory().getMainFileCache().getSize() / ByteConstants.MB;
    Preference cacheCleanPreference = getPreferenceManager().findPreference(KEY_PREF_CACHE_CLEAN);
    cacheCleanPreference.setSummary(String.format(" %.2f MB", size));

    LongClickPreference prefDownloadPath = (LongClickPreference) getPreferenceManager()
            .findPreference(KEY_PREF_DOWNLOAD_PATH);
    prefDownloadPath.setOnLongClickListener(v -> {
        new AlertDialog.Builder(activity).setTitle("?")
                .setItems(new String[] { "", "" },
                        (dialogInterface, pos) -> {
                            if (pos == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                                Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
                                intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
                                try {
                                    startActivityForResult(intent, RESULT_CHOOSE_DIRECTORY);
                                } catch (ActivityNotFoundException e) {
                                    e.printStackTrace();
                                    mDialog.show(getFragmentManager(), null);
                                }
                                new Handler().postDelayed(() -> {
                                    if (!opened)
                                        activity.showSnackBar(
                                                "?");
                                }, 1000);
                            } else if (pos == 1) {
                                mDialog.show(getFragmentManager(), null);
                            } else
                                activity.showSnackBar("???");
                        })
                .setNegativeButton(getString(R.string.cancel), null).show();
        return true;
    });
}

From source file:cx.ring.model.CallContact.java

public void displayContact(Context context) {
    if (context == null) {
        Log.d(TAG, "displayContact: context is null");
        return;/* w  w  w  .j  a va 2  s. c  o m*/
    }

    if (getId() == UNKNOWN_ID) {
        Log.d(TAG, "displayContact: contact is unknown");
        displayAddContactConfirmationDialog(context);
    } else {
        Log.d(TAG, "displayContact: contact is known, displaying...");
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(getId()));
            intent.setData(uri);
            context.startActivity(intent);
        } catch (ActivityNotFoundException exc) {
            exc.printStackTrace();
        }
    }
}

From source file:ml.puredark.hviewer.ui.fragments.SettingFragment.java

@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference.getKey().equals(KEY_PREF_ABOUT_UPGRADE)) {
        //// w  w  w  .ja  v a2s .c  o  m
        if (!checking)
            UpdateManager.checkUpdate(activity);
    } else if (preference.getKey().equals(KEY_PREF_BKRS_BACKUP)) {
        //
        new AlertDialog.Builder(activity).setTitle("?").setMessage("?")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    String backup = new DataBackup().DoBackup();
                    activity.showSnackBar(backup);
                }).setNegativeButton(getString(R.string.cancel), null).show();

    } else if (preference.getKey().equals(KEY_PREF_BKRS_RESTORE)) {
        //
        new AlertDialog.Builder(activity).setTitle("???")
                .setMessage("????")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    String restore = new DataRestore().DoRestore();
                    Intent intent = new Intent();
                    activity.setResult(RESULT_OK, intent);
                    Toast.makeText(activity, restore, Toast.LENGTH_LONG).show();
                    activity.finish();
                }).setNegativeButton(getString(R.string.cancel), null).show();

    } else if (preference.getKey().equals(KEY_PREF_ABOUT_LICENSE)) {
        //???
        Intent intent = new Intent(activity, LicenseActivity.class);
        startActivity(intent);
    } else if (preference.getKey().equals(KEY_PREF_ABOUT_PRIVACY)) {
        //???
        Intent intent = new Intent(activity, PrivacyActivity.class);
        startActivity(intent);
    } else if (preference.getKey().equals(KEY_PREF_ABOUT_H_VIEWER)) {
        //
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.setting_content, new AboutFragment(activity));
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(null);
        transaction.commit();
    } else if (preference.getKey().equals(KEY_PREF_DOWNLOAD_PATH)) {
        //
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
            intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
            try {
                startActivityForResult(intent, RESULT_CHOOSE_DIRECTORY);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
                mDialog.show(getFragmentManager(), null);
            }
            new Handler().postDelayed(() -> {
                if (!opened)
                    activity.showSnackBar("?");
            }, 1000);
        } else {
            mDialog.show(getFragmentManager(), null);
        }
    } else if (preference.getKey().equals(KEY_PREF_DOWNLOAD_IMPORT)) {
        //
        new AlertDialog.Builder(activity).setTitle("?")
                .setMessage("??")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    DownloadedImport();
                }).setNegativeButton(getString(R.string.cancel), null).show();
    } else if (preference.getKey().equals(KEY_PREF_FAVOURITE_EXPORT)) {
        //?
        new AlertDialog.Builder(activity).setTitle("??")
                .setMessage("?")
                .setPositiveButton("", (dialog, which) -> {
                    DocumentFile file = FileHelper.createFileIfNotExist(Names.favouritesname,
                            DownloadManager.getDownloadPath(), Names.backupdirname);
                    if (file != null) {
                        FavouriteHolder holder = new FavouriteHolder(activity);
                        String json = new Gson().toJson(holder.getFavourites());
                        FileHelper.writeString(json, file);
                        holder.onDestroy();
                        activity.showSnackBar("??");
                    } else
                        activity.showSnackBar("");
                }).setNegativeButton(getString(R.string.cancel), null).show();
    } else if (preference.getKey().equals(KEY_PREF_FAVOURITE_IMPORT)) {
        //?
        new AlertDialog.Builder(activity).setTitle("??")
                .setMessage("???")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    String json = FileHelper.readString(Names.favouritesname, DownloadManager.getDownloadPath(),
                            Names.backupdirname);
                    if (json == null) {
                        activity.showSnackBar("?");
                    } else {
                        try {
                            List<Pair<CollectionGroup, List<LocalCollection>>> favGroups = new Gson().fromJson(
                                    json,
                                    new TypeToken<ArrayList<Pair<CollectionGroup, ArrayList<LocalCollection>>>>() {
                                    }.getType());
                            FavouriteHolder holder = new FavouriteHolder(activity);
                            for (Pair<CollectionGroup, List<LocalCollection>> pair : favGroups) {
                                Logger.d("DataStore", "" + pair.first);
                                CollectionGroup group = holder.getGroupByTitle(pair.first.title);
                                if (group == null) {
                                    group = pair.first;
                                    group.gid = holder.addFavGroup(group);
                                }
                                for (LocalCollection collection : pair.second) {
                                    collection.gid = group.gid;
                                    holder.addFavourite(collection);
                                }
                            }
                            holder.onDestroy();
                            activity.showSnackBar("??");
                        } catch (Exception e) {
                            e.printStackTrace();
                            activity.showSnackBar("?");
                        }
                    }
                }).setNegativeButton(getString(R.string.cancel), null).show();
    } else if (preference.getKey().equals(KEY_PREF_CACHE_CLEAN)) {
        //
        new AlertDialog.Builder(activity).setTitle("?")
                .setMessage("??")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    ImagePipeline imagePipeline = Fresco.getImagePipeline();
                    imagePipeline.clearDiskCaches();
                    activity.showSnackBar("??");
                    preference.setSummary(" 0.00 MB");
                }).setNegativeButton(getString(R.string.cancel), null).show();
    } else if (preference.getKey().equals(KEY_PREF_PROXY_DETAIL)) {
        //PROXY?
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.setting_content, new ProxyFragment(activity));
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(null);
        transaction.commit();
    } else if (preference.getKey().equals(KEY_PREF_LOCK_METHODS_DETAIL)) {
        //??
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.setting_content, new LockMethodFragment(activity));
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(null);
        transaction.commit();
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
}

From source file:com.filemanager.free.fragments.preference_fragments.Preffrag.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceUtils.reset();/*from   www.j  av a2s .c  o  m*/
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);
    preferences = (com.filemanager.free.activities.Preferences) getActivity();
    sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());

    final int th1 = Integer.parseInt(sharedPref.getString("theme", "0"));
    theme = th1 == 2 ? PreferenceUtils.hourOfDay() : th1;
    /*findPreference("donate").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
        ((com.filemanager.free.activities.Preferences) getActivity()).donate();
        return false;
    }
    });*/
    findPreference("columns").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            final String[] sort = getResources().getStringArray(R.array.columns);
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.gridcolumnno);
            int current = Integer.parseInt(sharedPref.getString("columns", "-1"));
            current = current == -1 ? 0 : current;
            if (current != 0)
                current = current - 1;
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("columns", "" + (which != 0 ? sort[which] : "" + -1)).commit();
                    dialog.dismiss();
                    return true;
                }
            });
            a.build().show();
            return true;
        }
    });

    findPreference("theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            String[] sort = getResources().getStringArray(R.array.theme);
            int current = Integer.parseInt(sharedPref.getString("theme", "0"));
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("theme", "" + which).commit();
                    dialog.dismiss();
                    restartPC(getActivity());
                    return true;
                }
            });
            a.title(R.string.theme);
            a.build().show();
            return true;
        }
    });

    final SwitchPreference rootmode = (SwitchPreference) findPreference("rootmode");
    rootmode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            boolean b = sharedPref.getBoolean("rootmode", false);
            if (b) {
                if (RootTools.isAccessGiven()) {
                    rootmode.setChecked(true);

                } else {
                    rootmode.setChecked(false);

                    Toast.makeText(getActivity(), getResources().getString(R.string.rootfailure),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                rootmode.setChecked(false);

            }
            return false;
        }
    });

    //Directory sort mode
    findPreference("dirontop").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            String[] sort = getResources().getStringArray(R.array.directorysortmode);
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.directorysort);
            int current = Integer.parseInt(sharedPref.getString("dirontop", "0"));
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("dirontop", "" + which).commit();
                    dialog.dismiss();
                    return true;
                }
            });
            a.build().show();
            return true;
        }
    });

    findPreference("sortby").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            String[] sort = getResources().getStringArray(R.array.sortby);
            int current = Integer.parseInt(sharedPref.getString("sortby", "0"));
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("sortby", "" + which).commit();
                    dialog.dismiss();
                    return true;
                }
            });
            a.title(R.string.sortby);
            a.build().show();
            return true;
        }
    });

    // Feedback
    Preference preference3 = (Preference) findPreference("feedback");
    preference3.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", "hoanghiep8899@gmail.com", null));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback : File Manager");
            Toast.makeText(getActivity(), getActivity().getFilesDir().getPath(), Toast.LENGTH_SHORT).show();
            File f = new File(getActivity().getExternalFilesDir("internal"), "log.txt");
            if (f.exists()) {
                emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
            }
            startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.feedback)));
            return false;
        }
    });

    // rate
    Preference preference5 = (Preference) findPreference("rate");
    preference5.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent1 = new Intent(Intent.ACTION_VIEW);
            intent1.setData(Uri.parse("market://details?id=com.filemanager.free"));
            try {
                startActivity(intent1);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
            }
            return false;
        }
    });

    // Colored random color
    final SwitchPreference randomColor = (SwitchPreference) findPreference("random_checkbox");
    randomColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (preferences != null)
                preferences.changed = 1;
            Toast.makeText(getActivity(), R.string.setRandom, Toast.LENGTH_LONG).show();
            return true;
        }
    });
    // Colored navigation bar
    final SwitchPreference colorNavigation = (SwitchPreference) findPreference("colorednavigation");
    colorNavigation.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (preferences != null) {
                preferences.changed = 1;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(getResources().getString(R.string.confirm));
            builder.setMessage(getResources().getString(R.string.themeRestart));
            builder.setPositiveButton(getResources().getString(R.string.ok),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            restartPC(getActivity());
                        }
                    });
            builder.setNegativeButton(getResources().getString(R.string.cancel),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            builder.setCancelable(true);
            builder.show();
            return true;
        }
    });
    if (Build.VERSION.SDK_INT >= 21) {
        colorNavigation.setEnabled(true);
    } else {
        colorNavigation.setEnabled(false);
    }

    findPreference("skin").setOnPreferenceClickListener(this);
    findPreference("fab_skin").setOnPreferenceClickListener(this);
    findPreference("icon_skin").setOnPreferenceClickListener(this);
    findPreference("extractpath").setOnPreferenceClickListener(this);
    findPreference("zippath").setOnPreferenceClickListener(this);
}

From source file:in.codehex.arrow.MainActivity.java

/**
 * Prompt the user to say something/* w w w .  ja va  2  s .co m*/
 */
private void promptSpeechInput() {
    textToSpeech.stop();
    intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
    try {
        startActivityForResult(intent, Config.REQUEST_SPEECH_INPUT);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:com.amaze.filemanager.fragments.MainFragment.java

public static void launchSMB(final HybridFileParcelable baseFile, final Activity activity) {
    final Streamer s = Streamer.getInstance();
    new Thread() {
        public void run() {
            try {
                /*/*from   w w w.  j  a v  a  2 s. c  o m*/
                List<SmbFile> subtitleFiles = new ArrayList<SmbFile>();
                        
                // finding subtitles
                for (Layoutelements layoutelement : LIST_ELEMENTS) {
                SmbFile smbFile = new SmbFile(layoutelement.getDesc());
                if (smbFile.getName().contains(smbFile.getName())) subtitleFiles.add(smbFile);
                }
                */

                s.setStreamSrc(new SmbFile(baseFile.getPath()), baseFile.getSize());
                activity.runOnUiThread(() -> {
                    try {
                        Uri uri = Uri.parse(Streamer.URL + Uri
                                .fromFile(new File(Uri.parse(baseFile.getPath()).getPath())).getEncodedPath());
                        Intent i = new Intent(Intent.ACTION_VIEW);
                        i.setDataAndType(uri,
                                MimeTypes.getMimeType(baseFile.getPath(), baseFile.isDirectory()));
                        PackageManager packageManager = activity.getPackageManager();
                        List<ResolveInfo> resInfos = packageManager.queryIntentActivities(i, 0);
                        if (resInfos != null && resInfos.size() > 0)
                            activity.startActivity(i);
                        else
                            Toast.makeText(activity,
                                    activity.getResources().getString(R.string.smb_launch_error),
                                    Toast.LENGTH_SHORT).show();
                    } catch (ActivityNotFoundException e) {
                        e.printStackTrace();
                    }
                });

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }.start();
}

From source file:com.googlecode.CallerLookup.Main.java

public void doSubmit() {
    String entry = "";
    if (mLookup.getSelectedItemPosition() != 0) {
        entry = mLookup.getSelectedItem().toString() + "\n";
    }//  w  w w  .  j a  v a  2 s  . c om

    entry += mURL.getText().toString() + "\n";
    entry += mRegExp.getText().toString() + "\n";

    try {
        String[] mailto = { EMAIL_ADDRESS };
        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, EMAIL_SUBJECT);
        sendIntent.putExtra(Intent.EXTRA_TEXT, entry);
        sendIntent.setType("message/rfc822");
        startActivity(sendIntent);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();

        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setTitle(R.string.SubmitFailureTitle);
        alert.setMessage(R.string.SubmitFailureMessage);
        alert.setPositiveButton(android.R.string.ok, null);
        alert.show();
    }
}

From source file:org.dvbviewer.controller.ui.fragments.StreamConfig.java

@Override
public void onClick(View v) {
    Intent videoIntent = null;//  ww  w .ja  v  a 2 s. c  o m
    switch (v.getId()) {
    case R.id.startTranscodedButton:
        mStreamType = STREAM_TYPE_TRANSCODE;
        videoIntent = getVideoIntent();
        try {
            startActivity(videoIntent);
            if (UIUtils.isTablet(getActivity())) {
                getDialog().dismiss();
            } else {
                getActivity().finish();
            }
        } catch (ActivityNotFoundException e) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setMessage(getResources().getString(R.string.noFlashPlayerFound))
                    .setPositiveButton(getResources().getString(R.string.yes), this)
                    .setNegativeButton(getResources().getString(R.string.no), this).show();

            e.printStackTrace();
        }
        break;
    case R.id.startDirectButton:
        mStreamType = STREAM_TYPE_DIRECT;
        videoIntent = getVideoIntent();
        try {
            startActivity(videoIntent);
            if (UIUtils.isTablet(getActivity())) {
                getDialog().dismiss();
            } else {
                getActivity().finish();
            }
        } catch (ActivityNotFoundException e) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setMessage(getResources().getString(R.string.noFlashPlayerFound))
                    .setPositiveButton(getResources().getString(R.string.yes), this)
                    .setNegativeButton(getResources().getString(R.string.no), this).show();

            e.printStackTrace();
        }
        break;

    default:
        break;
    }
}

From source file:net.gsantner.opoc.util.ContextUtils.java

/**
 * Send a {@link Intent#ACTION_VIEW} Intent with given paramter
 * If the parameter is an string a browser will get triggered
 *///  w  w w  . j  a va  2 s .  c  o m
public void openWebpageInExternalBrowser(final String url) {
    Uri uri = Uri.parse(url);
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
    try {
        _context.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}