Example usage for android.content Intent CATEGORY_DEFAULT

List of usage examples for android.content Intent CATEGORY_DEFAULT

Introduction

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

Prototype

String CATEGORY_DEFAULT

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

Click Source Link

Document

Set if the activity should be an option for the default action (center press) to perform on a piece of data.

Usage

From source file:com.landenlabs.all_devtool.PackageFragment.java

/**
 * Open Application Detail Info dialog for package.
 *
 * @param packageName//  w w  w.  j  ava2s . co m
 */
void openPackageInfo(String packageName) {
    //redirect user to app Settings
    Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse("package:" + packageName));
    startActivity(intent);
}

From source file:org.transdroid.gui.TorrentsFragment.java

private void startBarcodeScanner() {

    // Test to see if the ZXing barcode scanner is available that can handle the SCAN intent
    Intent scan = new Intent(Transdroid.SCAN_INTENT);
    scan.addCategory(Intent.CATEGORY_DEFAULT);
    if (ActivityUtil.isIntentAvailable(getActivity(), scan)) {
        // Ask the barcode scanner to allow the user to scan some code
        startActivityForResult(scan, ACTIVITY_BARCODE);
    } else {// w  ww.jav  a 2 s  .c om
        // Show a message if the user should install the barcode scanner for this feature
        showDialog(DIALOG_INSTALLBARCODESCANNER);
    }

}

From source file:org.fox.ttrss.OnlineActivity.java

@Override
public void onResume() {
    super.onResume();

    ApiRequest.trustAllHosts(m_prefs.getBoolean("ssl_trust_any", false),
            m_prefs.getBoolean("ssl_trust_any_host", false));

    IntentFilter filter = new IntentFilter();
    filter.addAction(OfflineDownloadService.INTENT_ACTION_SUCCESS);
    filter.addAction(OfflineUploadService.INTENT_ACTION_SUCCESS);
    filter.addCategory(Intent.CATEGORY_DEFAULT);

    registerReceiver(m_broadcastReceiver, filter);

    if (getSessionId() == null) {
        login();//from  w ww .j  ava 2 s.co  m
    } else {
        loginSuccess(false);
    }
}

From source file:com.android.launcher3.Utilities.java

private static void applyChange(Activity context) {
    context.finish();/*from w w  w  . j  av  a 2s. c  om*/
    context.startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)
            .addCategory(Intent.CATEGORY_DEFAULT).addCategory(Intent.CATEGORY_HOME));
}

From source file:android.content.pm.PackageParser.java

private boolean parseIntent(Resources res, XmlPullParser parser, AttributeSet attrs, boolean allowGlobs,
        boolean allowAutoVerify, IntentInfo outInfo, String[] outError)
        throws XmlPullParserException, IOException {

    TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestIntentFilter);

    int priority = sa.getInt(com.android.internal.R.styleable.AndroidManifestIntentFilter_priority, 0);
    outInfo.setPriority(priority);/* www.  j  av  a2s  .  c o  m*/

    TypedValue v = sa.peekValue(com.android.internal.R.styleable.AndroidManifestIntentFilter_label);
    if (v != null && (outInfo.labelRes = v.resourceId) == 0) {
        outInfo.nonLocalizedLabel = v.coerceToString();
    }

    outInfo.icon = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestIntentFilter_icon, 0);

    outInfo.logo = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestIntentFilter_logo, 0);

    outInfo.banner = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestIntentFilter_banner, 0);

    if (allowAutoVerify) {
        outInfo.setAutoVerify(
                sa.getBoolean(com.android.internal.R.styleable.AndroidManifestIntentFilter_autoVerify, false));
    }

    sa.recycle();

    int outerDepth = parser.getDepth();
    int type;
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
        if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
            continue;
        }

        String nodeName = parser.getName();
        if (nodeName.equals("action")) {
            String value = attrs.getAttributeValue(ANDROID_RESOURCES, "name");
            if (value == null || value == "") {
                outError[0] = "No value supplied for <android:name>";
                return false;
            }
            XmlUtils.skipCurrentTag(parser);

            outInfo.addAction(value);
        } else if (nodeName.equals("category")) {
            String value = attrs.getAttributeValue(ANDROID_RESOURCES, "name");
            if (value == null || value == "") {
                outError[0] = "No value supplied for <android:name>";
                return false;
            }
            XmlUtils.skipCurrentTag(parser);

            outInfo.addCategory(value);

        } else if (nodeName.equals("data")) {
            sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestData);

            String str = sa.getNonConfigurationString(
                    com.android.internal.R.styleable.AndroidManifestData_mimeType, 0);
            if (str != null) {
                try {
                    outInfo.addDataType(str);
                } catch (IntentFilter.MalformedMimeTypeException e) {
                    outError[0] = e.toString();
                    sa.recycle();
                    return false;
                }
            }

            str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_scheme, 0);
            if (str != null) {
                outInfo.addDataScheme(str);
            }

            str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_ssp, 0);
            if (str != null) {
                outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_LITERAL);
            }

            str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_sspPrefix,
                    0);
            if (str != null) {
                outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_PREFIX);
            }

            str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_sspPattern,
                    0);
            if (str != null) {
                if (!allowGlobs) {
                    outError[0] = "sspPattern not allowed here; ssp must be literal";
                    return false;
                }
                outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_SIMPLE_GLOB);
            }

            String host = sa
                    .getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_host, 0);
            String port = sa
                    .getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_port, 0);
            if (host != null) {
                outInfo.addDataAuthority(host, port);
            }

            str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_path, 0);
            if (str != null) {
                outInfo.addDataPath(str, PatternMatcher.PATTERN_LITERAL);
            }

            str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_pathPrefix,
                    0);
            if (str != null) {
                outInfo.addDataPath(str, PatternMatcher.PATTERN_PREFIX);
            }

            str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_pathPattern,
                    0);
            if (str != null) {
                if (!allowGlobs) {
                    outError[0] = "pathPattern not allowed here; path must be literal";
                    return false;
                }
                outInfo.addDataPath(str, PatternMatcher.PATTERN_SIMPLE_GLOB);
            }

            sa.recycle();
            XmlUtils.skipCurrentTag(parser);
        } else if (!RIGID_PARSER) {
            Slog.w(TAG, "Unknown element under <intent-filter>: " + parser.getName() + " at "
                    + mArchiveSourcePath + " " + parser.getPositionDescription());
            XmlUtils.skipCurrentTag(parser);
        } else {
            outError[0] = "Bad element under <intent-filter>: " + parser.getName();
            return false;
        }
    }

    outInfo.hasDefault = outInfo.hasCategory(Intent.CATEGORY_DEFAULT);

    if (DEBUG_PARSER) {
        final StringBuilder cats = new StringBuilder("Intent d=");
        cats.append(outInfo.hasDefault);
        cats.append(", cat=");

        final Iterator<String> it = outInfo.categoriesIterator();
        if (it != null) {
            while (it.hasNext()) {
                cats.append(' ');
                cats.append(it.next());
            }
        }
        Slog.d(TAG, cats.toString());
    }

    return true;
}