Example usage for android.content Intent addCategory

List of usage examples for android.content Intent addCategory

Introduction

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

Prototype

public @NonNull Intent addCategory(String category) 

Source Link

Document

Add a new category to the intent.

Usage

From source file:io.selendroid.server.ServerInstrumentation.java

public void backgroundActivity() {
    activitiesReporter.setBackgroundActivity(activitiesReporter.getCurrentActivity());
    Intent homeIntent = new Intent(Intent.ACTION_MAIN);
    homeIntent.addCategory(Intent.CATEGORY_HOME);
    homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    getTargetContext().startActivity(homeIntent);
}

From source file:com.borqs.browser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    Log.i("OpenSearchSearchEng", "startSearch, query: " + query);
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {//from  w  ww. j av  a2 s.c  om
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the Browser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:com.android.stockbrowser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {/*from w  ww .  j  a va 2 s  .  co m*/
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the StockBrowser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:fr.mixit.android.ui.StarredActivity.java

/** Build and add "speakers" tab. */
private void setupSpeakersTab() {
    final TabHost host = getTabHost();

    final Intent intent = new Intent(Intent.ACTION_VIEW, MixItContract.Speakers.CONTENT_STARRED_URI);
    intent.addCategory(Intent.CATEGORY_TAB);

    // Speakers content comes from reused activity
    host.addTab(host.newTabSpec(TAG_SPEAKERS).setIndicator(buildIndicator(R.string.starred_speakers))
            .setContent(intent));/* w  w w . j  a  v  a  2 s .  co  m*/
}

From source file:com.android.browser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {/*w ww .  j a v a 2 s  . c o  m*/
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the Browser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:com.cyanogenmod.account.ui.SetupWizardActivity.java

private void finishSetup() {
    Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
    Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
    ((CMAccount) AppGlobals.getInitialApplication()).enableStatusBar();
    Intent intent = new Intent("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.HOME");
    disableSetupWizards(intent);/*  w w  w.j a  va  2s .co  m*/
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags());
    startActivity(intent);
    finish();
}

From source file:com.redhorse.quickstart.AppConfig.java

private void loadApps() {
    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    mAllApps = getPackageManager().queryIntentActivities(mainIntent, 0);
    mApps = new ArrayList<ResolveInfo>();
    mApps2 = new ArrayList<ResolveInfo>();
    Cursor c = dbStart.getAllItems();
    Iterator it1 = mAllApps.iterator();
    while (it1.hasNext()) {
        boolean found = false;
        ResolveInfo info = (ResolveInfo) it1.next();
        if (c.moveToFirst()) {
            do {/*from w  ww.  j ava 2 s. com*/
                int idColumn = c.getColumnIndex(dbStart.KEY_ROWID);
                int pkgnameColumn = c.getColumnIndex(dbStart.KEY_PKGNAME);
                int appnameColumn = c.getColumnIndex(dbStart.KEY_APPNAME);
                int contentColumn = c.getColumnIndex(dbStart.KEY_CONTENT);
                if (c.getString(pkgnameColumn).equals(info.activityInfo.packageName)
                        && c.getString(appnameColumn).equalsIgnoreCase(info.activityInfo.name)) {
                    found = true;
                    break;
                }
            } while (c.moveToNext());
        }
        if (!found)
            if (!info.activityInfo.packageName.equalsIgnoreCase("com.redhorse.quickstart"))
                mApps.add(info);
    }
    if (c.moveToFirst()) {
        do {
            int idColumn = c.getColumnIndex(dbStart.KEY_ROWID);
            int pkgnameColumn = c.getColumnIndex(dbStart.KEY_PKGNAME);
            int appnameColumn = c.getColumnIndex(dbStart.KEY_APPNAME);
            int contentColumn = c.getColumnIndex(dbStart.KEY_CONTENT);
            it1 = mAllApps.iterator();
            boolean found = false;
            ResolveInfo info = null;
            while (it1.hasNext()) {
                info = (ResolveInfo) it1.next();
                if (c.getString(pkgnameColumn).equals(info.activityInfo.packageName)
                        && c.getString(appnameColumn).equalsIgnoreCase(info.activityInfo.name)) {
                    found = true;
                    break;
                }
            }
            if (found)
                if (!info.activityInfo.packageName.equalsIgnoreCase("com.redhorse.quickstart"))
                    mApps2.add(info);
        } while (c.moveToNext());
    }
    c.close();
}

From source file:com.wodify.cordova.plugin.filepicker.FilePicker.java

/**
 * Pick file from device./*w w  w  .  java 2s  .c  o  m*/
 */
public void pickFile() {
    Intent intent = new Intent();

    // Any type of file may be picked
    intent.setType("*/*");

    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    if (this.cordova != null) {
        this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent, "Pick File"), 0);
    }
}

From source file:com.android.settings.SettingsLicenseActivity.java

private void showHtmlFromUri(Uri uri) {
    // Kick off external viewer due to WebView security restrictions; we
    // carefully point it at HTMLViewer, since it offers to decompress
    // before viewing.
    final Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(uri, "text/html");
    intent.putExtra(Intent.EXTRA_TITLE, getString(R.string.settings_license_activity_title));
    if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }/*from   ww w  .  j a va  2 s. c om*/
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setPackage("com.android.htmlviewer");

    try {
        startActivity(intent);
        finish();
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Failed to find viewer", e);
        showErrorAndFinish();
    }
}

From source file:com.android.talkback.labeling.LabelManagerSummaryActivity.java

private void addImportCustomLabelClickListener() {
    final Button importLabel = (Button) findViewById(R.id.import_labels);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        importLabel.setVisibility(View.GONE);
        return;/*from  ww  w  .  j  a va 2  s .c o m*/
    }
    importLabel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent importIntent = new Intent();
            importIntent.setAction(Intent.ACTION_GET_CONTENT);
            importIntent.setType("application/json");
            importIntent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(importIntent, SELECT_LABEL_FILE_REQUEST);
        }
    });
}