Example usage for android.content Intent CATEGORY_BROWSABLE

List of usage examples for android.content Intent CATEGORY_BROWSABLE

Introduction

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

Prototype

String CATEGORY_BROWSABLE

To view the source code for android.content Intent CATEGORY_BROWSABLE.

Click Source Link

Document

Activities that can be safely invoked from a browser must support this category.

Usage

From source file:cn.ieclipse.af.demo.MainActivity.java

@Override
public void onCheckSuccess(final CheckUpdateController.CheckResponse info) {
    if (info != null) {
        DialogUtils.showAlert(this, android.R.drawable.ic_dialog_info, "?",
                TextUtils.isEmpty(info.description) ? "???" : info.description,
                new DialogInterface.OnClickListener() {
                    @Override/*from   w w  w . jav  a 2s .  c om*/
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            Intent intent = new Intent(Intent.ACTION_VIEW);
                            intent.addCategory(Intent.CATEGORY_BROWSABLE);
                            intent.addCategory(Intent.CATEGORY_DEFAULT);
                            if (info.force) {
                                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            }
                            intent.setData(Uri.parse(info.downloadLink));
                            startActivityForResult(Intent.createChooser(intent, null), 0x01);
                        } catch (Exception e) {
                            DialogUtils.showToast(getApplicationContext(), "?");
                        } finally {

                        }
                    }
                }, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (info.force) {
                            finish();
                        }
                    }
                });
    }
}

From source file:com.dwdesign.tweetings.activity.ImageViewerActivity.java

@Override
public void onClick(final View view) {
    final Uri uri = getIntent().getData();
    switch (view.getId()) {
    case R.id.close: {
        onBackPressed();//w w w. ja va 2  s.c om
        break;
    }
    case R.id.refresh_stop_save: {
        if (!mImageLoaded && !mImageLoading) {
            loadImage();
        } else if (!mImageLoaded && mImageLoading) {
            stopLoading();
        } else if (mImageLoaded) {
            saveImage();
        }
        break;
    }
    case R.id.share: {
        if (uri == null) {
            break;
        }
        final Intent intent = new Intent(Intent.ACTION_SEND);
        final String scheme = uri.getScheme();
        if ("file".equals(scheme)) {
            intent.setType("image/*");
            intent.putExtra(Intent.EXTRA_STREAM, uri);
        } else {
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, uri.toString());
        }
        startActivity(Intent.createChooser(intent, getString(R.string.share)));
        break;
    }
    case R.id.open_in_browser: {
        if (uri == null) {
            break;
        }
        final String scheme = uri.getScheme();
        if ("http".equals(scheme) || "https".equals(scheme)) {
            final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            try {
                startActivity(intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
        }
        break;
    }
    }
}

From source file:de.vanita5.twittnuker.activity.support.MediaViewerActivity.java

public boolean onMenuItemClick(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SAVE: {
        if (mImageFile != null) {
            new SaveImageTask(this, mImageFile).execute();
        }// ww  w  .ja va 2s. c o  m
        break;
    }
    case MENU_OPEN_IN_BROWSER: {
        final Intent intent = getIntent();
        intent.setExtrasClassLoader(getClassLoader());
        final Uri uri = intent.getData();
        final Uri orig = intent.getParcelableExtra(EXTRA_URI_ORIG);
        final Uri uriPreferred = orig != null ? orig : uri;
        if (uriPreferred == null)
            return false;
        final String scheme = uriPreferred.getScheme();
        if ("http".equals(scheme) || "https".equals(scheme)) {
            final Intent open_intent = new Intent(Intent.ACTION_VIEW, uriPreferred);
            open_intent.addCategory(Intent.CATEGORY_BROWSABLE);
            try {
                startActivity(open_intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
        }
        break;
    }
    default: {
        final Intent intent = item.getIntent();
        if (intent != null) {
            try {
                startActivity(intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
            return true;
        }
        return false;
    }
    }
    return true;
}

From source file:com.chromium.fontinstaller.ui.settings.SettingsFragment.java

private boolean viewSource() {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    intent.setData(Uri.parse("https://github.com/ItsPriyesh/FontInstaller"));
    startActivity(intent);/*from  ww w  .ja v a  2 s  .  c  om*/
    return true;
}

From source file:com.dwdesign.gallery3d.app.ImageViewerGLActivity.java

@Override
public void onClick(final View view) {
    final Uri uri = getIntent().getData();
    switch (view.getId()) {
    case R.id.close: {
        onBackPressed();/*from  w ww  .  j  a  v a 2 s  . c o m*/
        break;
    }
    case R.id.refresh_stop_save: {
        final LoaderManager lm = getSupportLoaderManager();
        if (!mImageLoaded && !lm.hasRunningLoaders()) {
            loadImage();
        } else if (!mImageLoaded && lm.hasRunningLoaders()) {
            stopLoading();
        } else if (mImageLoaded) {
            new SaveImageTask(this, mImageFile).execute();
        }
        break;
    }
    case R.id.share: {
        if (uri == null) {
            break;
        }
        final Intent intent = new Intent(Intent.ACTION_SEND);
        if (mImageFile != null && mImageFile.exists()) {
            intent.setType("image/*");
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(mImageFile));
        } else {
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, uri.toString());
        }
        startActivity(Intent.createChooser(intent, getString(R.string.share)));
        break;
    }
    case R.id.open_in_browser: {
        if (uri == null) {
            break;
        }
        final String scheme = uri.getScheme();
        if ("http".equals(scheme) || "https".equals(scheme)) {
            final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            try {
                startActivity(intent);
            } catch (final ActivityNotFoundException e) {
                // Ignore.
            }
        }
        break;
    }
    }
}

From source file:com.purplefrog.glitchclocka.LearningReadout.java

/**
 * This intent can be activated two ways, by clicking on one of our AppWidgets, or is a callback from the OAuth mechanism.
 * This function returns true if we've been called from OAuth and need to harvest the auth data.
 * This function returns false if we've been activated by any other mechanism
 *//*from w w  w  .j a v a2s  . com*/
protected boolean checkStateMachine() {
    Intent intent = getIntent();

    if (intent.hasCategory(Intent.CATEGORY_BROWSABLE)) {
        final Uri uri = intent.getData();

        if (uri != null) {
            glitch.handleRedirect(uri, new MyGlitchSessionDelegate());
            return true;
        }
    }

    return false;
}

From source file:com.github.jobs.ui.fragment.JobDetailsFragment.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.company_url:
        Intent companyUrl = new Intent(Intent.ACTION_VIEW);
        companyUrl.addCategory(Intent.CATEGORY_BROWSABLE);
        companyUrl.setData(Uri.parse(mJob.getCompanyUrl()));
        startActivity(companyUrl);//from   w ww.ja v  a  2  s. c o  m
        break;
    }
}

From source file:com.doomy.decode.ResultDialogFragment.java

private void createURLIntent(String myURL) {
    Intent mIntent = new Intent();
    mIntent.setAction(Intent.ACTION_VIEW);
    mIntent.addCategory(Intent.CATEGORY_BROWSABLE);
    mIntent.setData(Uri.parse(myURL));/*from  w  w w .  ja v  a  2s .  c  om*/
    startActivity(mIntent);
}

From source file:org.jraf.android.hellomundo.app.pickwebcam.PickWebcamListFragment.java

@Override
public void showSource(String sourceUrl) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://" + sourceUrl));
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    getActivity().startActivity(intent);
}

From source file:org.liberty.android.fantastischmemo.ui.SettingsScreen.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.save:
        SaveButtonTask task = new SaveButtonTask();
        task.execute((Void) null);
        return true;

    case R.id.load_default:
        new AlertDialog.Builder(this).setTitle(R.string.load_default_text)
                .setMessage(R.string.load_default_warning_text)
                .setPositiveButton(R.string.ok_text, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        LoadDefaultTask task = new LoadDefaultTask();
                        task.execute((Void) null);
                        // Need to refresh the activity that invoke this activity.
                        Intent resultIntent = new Intent();
                        setResult(Activity.RESULT_OK, resultIntent);
                    }/*w  w w.  j  av  a2  s .  co  m*/
                }).setNegativeButton(R.string.cancel_text, null).show();
        return true;

    case R.id.settingsmenu_help:
        Intent myIntent = new Intent();
        myIntent.setAction(Intent.ACTION_VIEW);
        myIntent.addCategory(Intent.CATEGORY_BROWSABLE);
        myIntent.setData(Uri.parse(WEBSITE_HELP_SETTINGS));
        startActivity(myIntent);
        return true;

    }
    return false;
}