Example usage for android.content Intent CATEGORY_APP_MARKET

List of usage examples for android.content Intent CATEGORY_APP_MARKET

Introduction

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

Prototype

String CATEGORY_APP_MARKET

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

Click Source Link

Document

This activity allows the user to browse and download new applications.

Usage

From source file:com.android.launcher2.Launcher.java

/**
 * Sets the app market icon/*w  ww. ja v  a 2  s  .co  m*/
 */
private void updateAppMarketIcon() {
    final View marketButton = findViewById(R.id.market_button);
    Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET);
    // Find the app market activity by resolving an intent.
    // (If multiple app markets are installed, it will return the ResolverActivity.)
    ComponentName activityName = intent.resolveActivity(getPackageManager());
    if (activityName != null) {
        int coi = getCurrentOrientationIndexForGlobalIcons();
        mAppMarketIntent = intent;
        sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity(R.id.market_button, activityName,
                R.drawable.ic_launcher_market_holo, TOOLBAR_ICON_METADATA_NAME);
        marketButton.setVisibility(View.VISIBLE);
    } else {
        // We should hide and disable the view so that we don't try and restore the visibility
        // of it when we swap between drag & normal states from IconDropTarget subclasses.
        marketButton.setVisibility(View.GONE);
        marketButton.setEnabled(false);
    }
}

From source file:com.android.soma.Launcher.java

/**
 * Sets the app market icon//from   w ww. jav  a2 s.c  o  m
 */
private void updateAppMarketIcon() {
    if (!DISABLE_MARKET_BUTTON) {
        final View marketButton = findViewById(R.id.market_button);
        Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET);
        // Find the app market activity by resolving an intent.
        // (If multiple app markets are installed, it will return the ResolverActivity.)
        ComponentName activityName = intent.resolveActivity(getPackageManager());
        if (activityName != null) {
            int coi = getCurrentOrientationIndexForGlobalIcons();
            mAppMarketIntent = intent;
            sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity(R.id.market_button, activityName,
                    R.drawable.ic_launcher_market_holo, TOOLBAR_ICON_METADATA_NAME);
            marketButton.setVisibility(View.VISIBLE);
        } else {
            // We should hide and disable the view so that we don't try and restore the visibility
            // of it when we swap between drag & normal states from IconDropTarget subclasses.
            marketButton.setVisibility(View.GONE);
            marketButton.setEnabled(false);
        }
    }
}