Example usage for android.content.pm PackageManager GET_ACTIVITIES

List of usage examples for android.content.pm PackageManager GET_ACTIVITIES

Introduction

In this page you can find the example usage for android.content.pm PackageManager GET_ACTIVITIES.

Prototype

int GET_ACTIVITIES

To view the source code for android.content.pm PackageManager GET_ACTIVITIES.

Click Source Link

Document

PackageInfo flag: return information about activities in the package in PackageInfo#activities .

Usage

From source file:org.catrobat.catroid.ui.WebViewActivity.java

private boolean isWhatsappInstalled() {
    PackageManager packageManager = getPackageManager();
    try {/*from www .  j a v  a2s. c  o m*/
        packageManager.getPackageInfo(PACKAGE_NAME_WHATSAPP, PackageManager.GET_ACTIVITIES);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        return false;
    }
}

From source file:org.durka.hallmonitor.CoreStateManager.java

public boolean getDefaultActivityRunning() {
    try {/*from w  ww. ja va2  s .  com*/
        ActivityInfo[] list = mAppContext.getPackageManager().getPackageInfo(mAppContext.getPackageName(),
                PackageManager.GET_ACTIVITIES).activities;
        for (int i = 0; i < list.length; i++) {
            if (list[i].name == "org.durka.hallmonitor.DefaultActivity") {
                return true;
            }
        }
    } catch (NameNotFoundException e1) {
    }
    return false;
}

From source file:nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AbstractAppManagerFragment.java

public boolean openPopupMenu(View view, int position) {
    PopupMenu popupMenu = new PopupMenu(getContext(), view);
    popupMenu.getMenuInflater().inflate(R.menu.appmanager_context, popupMenu.getMenu());
    Menu menu = popupMenu.getMenu();
    final GBDeviceApp selectedApp = appList.get(position);

    if (!selectedApp.isInCache()) {
        menu.removeItem(R.id.appmanager_app_reinstall);
        menu.removeItem(R.id.appmanager_app_delete_cache);
    }//  ww w.  j  a va 2 s .  c  o  m
    if (!PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) {
        menu.removeItem(R.id.appmanager_health_activate);
        menu.removeItem(R.id.appmanager_health_deactivate);
    }
    if (!PebbleProtocol.UUID_WORKOUT.equals(selectedApp.getUUID())) {
        menu.removeItem(R.id.appmanager_hrm_activate);
        menu.removeItem(R.id.appmanager_hrm_deactivate);
    }
    if (!PebbleProtocol.UUID_WEATHER.equals(selectedApp.getUUID())) {
        menu.removeItem(R.id.appmanager_weather_activate);
        menu.removeItem(R.id.appmanager_weather_deactivate);
        menu.removeItem(R.id.appmanager_weather_install_provider);
    }
    if (selectedApp.getType() == GBDeviceApp.Type.APP_SYSTEM
            || selectedApp.getType() == GBDeviceApp.Type.WATCHFACE_SYSTEM) {
        menu.removeItem(R.id.appmanager_app_delete);
    }
    if (!selectedApp.isConfigurable()) {
        menu.removeItem(R.id.appmanager_app_configure);
    }

    if (PebbleProtocol.UUID_WEATHER.equals(selectedApp.getUUID())) {
        PackageManager pm = getActivity().getPackageManager();
        try {
            pm.getPackageInfo("ru.gelin.android.weather.notification", PackageManager.GET_ACTIVITIES);
            menu.removeItem(R.id.appmanager_weather_install_provider);
        } catch (PackageManager.NameNotFoundException e) {
            menu.removeItem(R.id.appmanager_weather_activate);
            menu.removeItem(R.id.appmanager_weather_deactivate);
        }
    }

    switch (selectedApp.getType()) {
    case WATCHFACE:
    case APP_GENERIC:
    case APP_ACTIVITYTRACKER:
        break;
    default:
        menu.removeItem(R.id.appmanager_app_openinstore);
    }
    //menu.setHeaderTitle(selectedApp.getName());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            return onContextItemSelected(item, selectedApp);
        }
    });

    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    popupMenu.show();
    return true;
}

From source file:org.durka.hallmonitor.CoreStateManager.java

public boolean getConfigurationActivityRunning() {
    try {/*from   w w  w .  j  a va2  s  .co  m*/
        ActivityInfo[] list = mAppContext.getPackageManager().getPackageInfo(mAppContext.getPackageName(),
                PackageManager.GET_ACTIVITIES).activities;
        for (int i = 0; i < list.length; i++) {
            if (list[i].name == "org.durka.hallmonitor.DefaultActivity") {
                return true;
            }
        }
    } catch (NameNotFoundException e1) {
    }
    return false;
}

From source file:it.mb.whatshare.MainActivity.java

/**
 * Checks whether Whatsapp is installed on this device.
 * /*www  .  ja va 2 s.  c o  m*/
 * @param activity
 *            the calling activity
 * @return <code>true</code> if a whatsapp installation is found locally
 */
static boolean isWhatsappInstalled(Context activity) {
    boolean installed = false;
    try {
        activity.getPackageManager().getPackageInfo(WHATSAPP_PACKAGE, PackageManager.GET_ACTIVITIES);
        installed = true;
    } catch (PackageManager.NameNotFoundException e) {
        // not installed
    }
    return installed;
}

From source file:com.github.michalbednarski.intentslab.browser.ComponentFetcher.java

@Override
void initConfigurationForm(final FetcherOptionsDialog dialog) {
    // Disable development permission checkbox if it's not available
    if (!DEVELOPMENT_PERMISSIONS_SUPPORTED) {
        dialog.findView(R.id.permission_filter_development).setEnabled(false);
    }/*  ww w. j  av a2s .c  om*/

    // Prepare protection preset spinner
    {
        // Find current preset
        int currentPresetId = PROTECTION_PRESETS.length; // "Custom" if nothing found
        if (!testWritePermissionForProviders) {
            for (int i = 0; i < PROTECTION_PRESETS.length; i++) {
                if (protection == PROTECTION_PRESETS[i]) {
                    currentPresetId = i;
                    dialog.findView(R.id.permission_filter_details).setVisibility(View.GONE);
                    break;
                }
            }
        }

        // Fill spinner
        Spinner protectionPresetSpinner = (Spinner) dialog.findView(R.id.permission_filter_spinner);
        Activity activity = dialog.getActivity();
        protectionPresetSpinner
                .setAdapter(new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_item,
                        new String[] { activity.getString(R.string.permission_filter_show_all), // 0
                                activity.getString(R.string.permission_filter_show_exported), // 1
                                activity.getString(R.string.permission_filter_show_obtainable), // 2
                                activity.getString(R.string.permission_filter_world_accessible), // 3
                                activity.getString(R.string.filter_custom) // 4
                        }));
        protectionPresetSpinner.setSelection(currentPresetId);

        // Set up spinner event
        protectionPresetSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                boolean isCustom = position == PROTECTION_PRESETS.length;
                if (!isCustom) {
                    int preset = PROTECTION_PRESETS[position];
                    dialog.setBoxChecked(R.id.permission_filter_world_accessible,
                            (preset & PROTECTION_WORLD_ACCESSIBLE) != 0);
                    dialog.setBoxChecked(R.id.permission_filter_normal, (preset & PROTECTION_NORMAL) != 0);
                    dialog.setBoxChecked(R.id.permission_filter_dangerous,
                            (preset & PROTECTION_DANGEROUS) != 0);
                    dialog.setBoxChecked(R.id.permission_filter_signature,
                            (preset & PROTECTION_SIGNATURE) != 0);
                    dialog.setBoxChecked(R.id.permission_filter_system, (preset & PROTECTION_SYSTEM) != 0);
                    dialog.setBoxChecked(R.id.permission_filter_development,
                            (preset & PROTECTION_DEVELOPMENT) != 0);
                    dialog.setBoxChecked(R.id.permission_filter_unexported,
                            (preset & PROTECTION_UNEXPORTED) != 0);
                    dialog.setBoxChecked(R.id.permission_filter_unknown, (preset & PROTECTION_UNKNOWN) != 0);
                    dialog.setBoxChecked(R.id.read_permission, true);
                }
                dialog.findView(R.id.permission_filter_details)
                        .setVisibility(isCustom ? View.VISIBLE : View.GONE);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                // Spinner cannot have nothing selected
            }
        });
    }

    // Fill form
    dialog.setBoxChecked(R.id.system_apps, (appType & APP_TYPE_SYSTEM) != 0);
    dialog.setBoxChecked(R.id.user_apps, (appType & APP_TYPE_USER) != 0);

    dialog.setBoxChecked(R.id.activities, (type & PackageManager.GET_ACTIVITIES) != 0);
    dialog.setBoxChecked(R.id.receivers, (type & PackageManager.GET_RECEIVERS) != 0);
    dialog.setBoxChecked(R.id.services, (type & PackageManager.GET_SERVICES) != 0);
    dialog.setBoxChecked(R.id.content_providers, (type & PackageManager.GET_PROVIDERS) != 0);

    dialog.setBoxChecked(R.id.permission_filter_world_accessible,
            (protection & PROTECTION_WORLD_ACCESSIBLE) != 0);
    dialog.setBoxChecked(R.id.permission_filter_normal, (protection & PROTECTION_NORMAL) != 0);
    dialog.setBoxChecked(R.id.permission_filter_dangerous, (protection & PROTECTION_DANGEROUS) != 0);
    dialog.setBoxChecked(R.id.permission_filter_signature, (protection & PROTECTION_SIGNATURE) != 0);
    dialog.setBoxChecked(R.id.permission_filter_system, (protection & PROTECTION_SYSTEM) != 0);
    dialog.setBoxChecked(R.id.permission_filter_development, (protection & PROTECTION_DEVELOPMENT) != 0);
    dialog.setBoxChecked(R.id.permission_filter_unexported, (protection & PROTECTION_UNEXPORTED) != 0);
    dialog.setBoxChecked(R.id.permission_filter_unknown, (protection & PROTECTION_UNKNOWN) != 0);

    dialog.setBoxChecked(testWritePermissionForProviders ? R.id.write_permission : R.id.read_permission, true);
    dialog.setBoxChecked(R.id.only_providers_with_grant_uri_permission,
            includeOnlyProvidersAllowingPermissionGranting);

    dialog.setBoxChecked(R.id.metadata, requireMetaDataSubstring != null);
    dialog.setTextInField(R.id.metadata_substring, requireMetaDataSubstring);

    // Set up sections showing when their checkboxes are checked
    dialog.findView(R.id.content_provider_permission_type)
            .setVisibility(testWritePermissionForProviders ? View.VISIBLE : View.GONE);
    dialog.findView(R.id.content_provider_options)
            .setVisibility((type & PackageManager.GET_PROVIDERS) != 0 ? View.VISIBLE : View.GONE);
    ((CheckBox) dialog.findView(R.id.content_providers))
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    dialog.findView(R.id.content_provider_permission_type)
                            .setVisibility(isChecked ? View.VISIBLE : View.GONE);
                    dialog.findView(R.id.content_provider_options)
                            .setVisibility(isChecked ? View.VISIBLE : View.GONE);
                    if (!isChecked) {
                        dialog.setBoxChecked(R.id.read_permission, true);
                        dialog.setBoxChecked(R.id.only_providers_with_grant_uri_permission, false);
                    }
                }
            });

    dialog.findView(R.id.metadata_details)
            .setVisibility(requireMetaDataSubstring != null ? View.VISIBLE : View.GONE);
    ((CheckBox) dialog.findView(R.id.metadata))
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    dialog.findView(R.id.metadata_details).setVisibility(isChecked ? View.VISIBLE : View.GONE);
                    if (!isChecked) {
                        dialog.setTextInField(R.id.metadata_substring, "");
                    }
                }
            });
}

From source file:ro.expectations.expenses.ui.backup.BackupFragment.java

private boolean isFinancistoInstalled() {
    PackageManager pm = getActivity().getPackageManager();
    boolean installed;
    try {/*from   ww w.ja  va2  s  .  co  m*/
        pm.getPackageInfo("ru.orangesoftware.financisto", PackageManager.GET_ACTIVITIES);
        installed = true;
    } catch (PackageManager.NameNotFoundException e) {
        installed = false;
    }
    return installed;
}

From source file:com.att.android.arodatacollector.utils.AROCollectorUtils.java

/**
 * Retrieves overall information about the specified application package
 * //from  ww  w  .j a v  a 2s .c om
 * @param pm
 *            The package manager instance.
 * @param name
 *            The package name.
 * 
 * @return Returns information about the package or null if the package
 *         could not be successfully parsed.
 */
public static PackageInfo getPackageInfo(PackageManager pm, String name) {
    PackageInfo ret = null;
    try {
        ret = pm.getPackageInfo(name, PackageManager.GET_ACTIVITIES);
    } catch (NameNotFoundException e) {
        AROLogger.e(TAG, "Exception in getPackageInfo" + e);
    }
    return ret;
}

From source file:io.flutter.embedding.android.FlutterActivity.java

/**
 * The Dart entrypoint that will be executed as soon as the Dart snapshot is loaded.
 * <p>//from  w w w  . ja v a 2s . c  om
 * This preference can be controlled with 2 methods:
 * <ol>
 *   <li>Pass a {@code String} as {@link #EXTRA_DART_ENTRYPOINT} with the launching {@code Intent}, or</li>
 *   <li>Set a {@code <meta-data>} called {@link #DART_ENTRYPOINT_META_DATA_KEY} for this
 *       {@code Activity} in the Android manifest.</li>
 * </ol>
 * If both preferences are set, the {@code Intent} preference takes priority.
 * <p>
 * The reason that a {@code <meta-data>} preference is supported is because this {@code Activity}
 * might be the very first {@code Activity} launched, which means the developer won't have
 * control over the incoming {@code Intent}.
 * <p>
 * Subclasses may override this method to directly control the Dart entrypoint.
 */
@NonNull
protected String getDartEntrypoint() {
    if (getIntent().hasExtra(EXTRA_DART_ENTRYPOINT)) {
        return getIntent().getStringExtra(EXTRA_DART_ENTRYPOINT);
    }

    try {
        ActivityInfo activityInfo = getPackageManager().getActivityInfo(getComponentName(),
                PackageManager.GET_META_DATA | PackageManager.GET_ACTIVITIES);
        Bundle metadata = activityInfo.metaData;
        String desiredDartEntrypoint = metadata != null ? metadata.getString(DART_ENTRYPOINT_META_DATA_KEY)
                : null;
        return desiredDartEntrypoint != null ? desiredDartEntrypoint : DEFAULT_DART_ENTRYPOINT;
    } catch (PackageManager.NameNotFoundException e) {
        return DEFAULT_DART_ENTRYPOINT;
    }
}

From source file:com.nookdevs.market.NookMarket.java

private void init() {
    displayAlert(getString(R.string.connecting), getString(R.string.please_wait), 1, null, -1);
    installedApps.clear();//from  w w w . j  a  va2  s .  c o  m
    availableApps.clear();
    documents.clear();
    m_Content.removeAllViews();
    PackageManager manager = getPackageManager();
    final List<PackageInfo> apps = manager.getInstalledPackages(PackageManager.GET_ACTIVITIES);
    for (PackageInfo app : apps) {
        if (app.packageName.equals("com.kbs.nooklet")) {
            m_NookletInstalled = true;
            File f = new File(SDFOLDER + "/nooklets");
            if (!f.exists()) {
                f = new File(EXTERNAL_SDFOLDER + "/nooklets");
                if (!f.exists()) {
                    m_NookletInstalled = false;
                }
                System.out.println("Nook Installed =" + m_NookletInstalled);
            }
            m_NookletFolder = f.getAbsolutePath();
        }
        installedApps.put(app.packageName, app);
    }
    WifiTask task = new WifiTask();
    task.execute();

}