List of usage examples for android.content.pm PackageManager GET_ACTIVITIES
int GET_ACTIVITIES
To view the source code for android.content.pm PackageManager GET_ACTIVITIES.
Click Source Link
From source file:uk.ac.hutton.ics.buntata.activity.MainActivity.java
protected void showWhatsNew() { try {/* www .j a v a 2 s . c o m*/ /* Get the versionCode of the Package, which must be different (incremented) in each release on the market in the AndroidManifest.xml */ final PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES); int lastVersionCode = PreferenceUtils.getPreferenceAsInt(this, PreferenceUtils.PREFS_LAST_VERSION, -1); /* If this is the first start, show nothing just remember the version number */ if (lastVersionCode == -1) { PreferenceUtils.setPreferenceAsInt(this, PreferenceUtils.PREFS_LAST_VERSION, packageInfo.versionCode); } /* Else show what's new if version numbers differ */ else { if (packageInfo.versionCode > lastVersionCode) { startActivity(new Intent(getApplicationContext(), ChangelogActivity.class)); } } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } }
From source file:com.popdeem.sdk.uikit.fragment.PDUIShareMessageFragment.java
public Boolean checkFbInstalled() { PackageManager pm = getActivity().getPackageManager(); boolean flag = false; try {//from ww w . j ava 2 s. c o m pm.getPackageInfo("com.facebook.katana", PackageManager.GET_ACTIVITIES); flag = true; } catch (PackageManager.NameNotFoundException e) { flag = false; } return flag; }
From source file:com.github.michalbednarski.intentslab.browser.BrowseComponentsFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (mFetcher.onOptionsItemSelected(itemId)) { setFetcher(mFetcher);/*from w w w. ja v a 2s.com*/ return true; } switch (itemId) { case R.id.custom_filter: FetcherOptionsDialog fetcherOptionsDialog = new FetcherOptionsDialog(); fetcherOptionsDialog.setTargetFragment(this, 0); fetcherOptionsDialog.show(getFragmentManager(), "filterOptions"); return true; case R.id.activities: case R.id.broadcasts: case R.id.services: case R.id.content_providers: { // Fetcher isn't component fetcher, otherwise it would intercept this above ComponentFetcher fetcher = new ComponentFetcher(); fetcher.type = itemId == R.id.activities ? PackageManager.GET_ACTIVITIES : itemId == R.id.broadcasts ? PackageManager.GET_RECEIVERS : itemId == R.id.services ? PackageManager.GET_SERVICES : itemId == R.id.content_providers ? PackageManager.GET_PROVIDERS : 0; if (mFetcher instanceof ApplicationFetcher) { fetcher.appType = ((ApplicationFetcher) mFetcher).appType; } setFetcher(fetcher); return true; } case R.id.applications: { if (!(mFetcher instanceof ApplicationFetcher)) { ApplicationFetcher fetcher = new ApplicationFetcher(); if (mFetcher instanceof ComponentFetcher) { fetcher.appType = ((ComponentFetcher) mFetcher).appType; } setFetcher(fetcher); } return true; } } return super.onOptionsItemSelected(item); }
From source file:io.flutter.embedding.engine.android.FlutterActivity.java
/** * The Dart entrypoint that will be executed as soon as the Dart snapshot is loaded. * <p>/*from w w w .jav a 2 s . com*/ * 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. */ @Nullable 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; return metadata != null ? metadata.getString(DART_ENTRYPOINT_META_DATA_KEY) : null; } catch (PackageManager.NameNotFoundException e) { return null; } }
From source file:net.net76.lifeiq.TaskiQ.RegisterActivity.java
private PackageInfo getPackageInfo() { PackageInfo info = null;/*from ww w.j a v a 2s .c o m*/ try { info = getApplicationContext().getPackageManager() .getPackageInfo(getApplicationContext().getPackageName(), PackageManager.GET_ACTIVITIES); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return info; }
From source file:com.popdeem.sdk.core.utils.PDSocialUtils.java
/** * Check if user has Instagram installed * * @param pm PackageManger//from ww w. jav a 2 s . c o m * @return true if Instagram is installed, false if it is not */ public static boolean hasInstagramAppInstalled(PackageManager pm) { try { pm.getPackageInfo("com.instagram.android", PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:org.deviceconnect.android.manager.core.util.DConnectUtil.java
/** * AndroidManifest.xml?versionName??.// ww w .j av a 2 s . c om * * @param context Context * @return versionName */ public static String getVersionName(final Context context) { PackageManager packageManager = context.getPackageManager(); try { PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES); return packageInfo.versionName; } catch (NameNotFoundException e) { return "Unknown"; } }
From source file:com.patil.geobells.lite.MainActivity.java
private boolean isAppInstalled(String packageName) { PackageManager pm = getPackageManager(); boolean installed = false; try {/*from w ww.j a va 2 s . c o m*/ pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); installed = true; } catch (PackageManager.NameNotFoundException e) { installed = false; } return installed; }
From source file:org.jssec.android.privacypolicy.MainActivity.java
private int getVersionCode() { int versionCode = -1; PackageManager packageManager = this.getPackageManager(); try {//w ww . ja v a 2 s .c om PackageInfo packageInfo = packageManager.getPackageInfo(this.getPackageName(), PackageManager.GET_ACTIVITIES); versionCode = packageInfo.versionCode; } catch (NameNotFoundException e) { // ?? } return versionCode; }
From source file:com.dm.material.dashboard.candybar.helpers.RequestHelper.java
public static void checkPiracyApp(@NonNull Context context) { boolean premiumRequest = context.getResources().getBoolean(R.bool.enable_premium_request); //Dashboard don't need to check piracy app if premium request is disabled if (!premiumRequest) { Preferences.getPreferences(context).setPremiumRequestEnabled(false); RequestListener listener = (RequestListener) context; listener.onPiracyAppChecked(true); return;//ww w. jav a 2s . co m } //Lucky Patcher and Freedom package name String[] strings = new String[] { "com.chelpus.lackypatch", "com.dimonvideo.luckypatcher", "com.forpda.lp", //"com.android.protips", This is not lucky patcher or freedom "com.android.vending.billing.InAppBillingService.LUCK", "com.android.vending.billing.InAppBillingService.LOCK", "cc.madkite.freedom", "com.android.vending.billing.InAppBillingService.LACK" }; boolean isPiracyAppInstalled = false; for (String string : strings) { try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(string, PackageManager.GET_ACTIVITIES); if (packageInfo != null) { isPiracyAppInstalled = true; break; } } catch (Exception ignored) { } } Preferences.getPreferences(context).setPremiumRequestEnabled(!isPiracyAppInstalled); RequestListener listener = (RequestListener) context; listener.onPiracyAppChecked(isPiracyAppInstalled); }