List of usage examples for android.content.pm PackageManager GET_META_DATA
int GET_META_DATA
To view the source code for android.content.pm PackageManager GET_META_DATA.
Click Source Link
From source file:com.ccxt.whl.DemoApplication.java
private String getAppName(int pID) { String processName = null;/*from w ww . j a va 2s.co m*/ ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List l = am.getRunningAppProcesses(); Iterator i = l.iterator(); PackageManager pm = this.getPackageManager(); while (i.hasNext()) { ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo) (i.next()); try { if (info.pid == pID) { CharSequence c = pm.getApplicationLabel( pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA)); // Log.d("Process", "Id: "+ info.pid +" ProcessName: "+ // info.processName +" Label: "+c.toString()); // processName = c.toString(); processName = info.processName; return processName; } } catch (Exception e) { // Log.d("Process", "Error>> :"+ e.toString()); } } return processName; }
From source file:com.facebook.FacebookSdk.java
static void loadDefaultsFromMetadata(Context context) { if (context == null) { return;//w ww . ja v a 2s .co m } ApplicationInfo ai = null; try { ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { return; } if (ai == null || ai.metaData == null) { return; } if (applicationId == null) { Object appId = ai.metaData.get(APPLICATION_ID_PROPERTY); if (appId instanceof String) { applicationId = (String) appId; } else if (appId instanceof Integer) { applicationId = appId.toString(); } } if (applicationName == null) { applicationName = ai.metaData.getString(APPLICATION_NAME_PROPERTY); } if (appClientToken == null) { appClientToken = ai.metaData.getString(CLIENT_TOKEN_PROPERTY); } if (webDialogTheme == 0) { setWebDialogTheme(ai.metaData.getInt(WEB_DIALOG_THEME)); } }
From source file:plugin.google.maps.GoogleMaps.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void getMap(JSONArray args, final CallbackContext callbackContext) throws JSONException { if (map != null) { callbackContext.success();// w w w . j av a 2 s. c o m return; } mPluginLayout = new MyPluginLayout(webView, activity); // ------------------------------ // Check of Google Play Services // ------------------------------ int checkGooglePlayServices = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity); if (checkGooglePlayServices != ConnectionResult.SUCCESS) { // google play services is missing!!!! /* * Returns status code indicating whether there was an error. Can be one * of following in ConnectionResult: SUCCESS, SERVICE_MISSING, * SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID. */ Log.e("CordovaLog", "---Google Play Services is not available: " + GooglePlayServicesUtil.getErrorString(checkGooglePlayServices)); Dialog errorDialog = null; try { //errorDialog = GooglePlayServicesUtil.getErrorDialog(checkGooglePlayServices, activity, 1); Method getErrorDialogMethod = GooglePlayServicesUtil.class.getMethod("getErrorDialog", int.class, Activity.class, int.class); errorDialog = (Dialog) getErrorDialogMethod.invoke(null, checkGooglePlayServices, activity, 1); } catch (Exception e) { } ; if (errorDialog != null) { errorDialog.show(); } else { boolean isNeedToUpdate = false; String errorMsg = "Google Maps Android API v2 is not available for some reason on this device. Do you install the latest Google Play Services from Google Play Store?"; switch (checkGooglePlayServices) { //case ConnectionResult.DATE_INVALID: // errorMsg = "It seems your device date is set incorrectly. Please update the correct date and time."; // break; case ConnectionResult.DEVELOPER_ERROR: errorMsg = "The application is misconfigured. This error is not recoverable and will be treated as fatal. The developer should look at the logs after this to determine more actionable information."; break; case ConnectionResult.INTERNAL_ERROR: errorMsg = "An internal error of Google Play Services occurred. Please retry, and it should resolve the problem."; break; case ConnectionResult.INVALID_ACCOUNT: errorMsg = "You attempted to connect to the service with an invalid account name specified."; break; case ConnectionResult.LICENSE_CHECK_FAILED: errorMsg = "The application is not licensed to the user. This error is not recoverable and will be treated as fatal."; break; case ConnectionResult.NETWORK_ERROR: errorMsg = "A network error occurred. Please retry, and it should resolve the problem."; break; case ConnectionResult.SERVICE_DISABLED: errorMsg = "The installed version of Google Play services has been disabled on this device. Please turn on Google Play Services."; break; case ConnectionResult.SERVICE_INVALID: errorMsg = "The version of the Google Play services installed on this device is not authentic. Please update the Google Play Services from Google Play Store."; isNeedToUpdate = true; break; case ConnectionResult.SERVICE_MISSING: errorMsg = "Google Play services is missing on this device. Please install the Google Play Services."; isNeedToUpdate = true; break; case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED: errorMsg = "The installed version of Google Play services is out of date. Please update the Google Play Services from Google Play Store."; isNeedToUpdate = true; break; case ConnectionResult.SIGN_IN_REQUIRED: errorMsg = "You attempted to connect to the service but you are not signed in. Please check the Google Play Services configuration"; break; default: isNeedToUpdate = true; break; } final boolean finalIsNeedToUpdate = isNeedToUpdate; AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity); alertDialogBuilder.setMessage(errorMsg).setCancelable(false).setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); if (finalIsNeedToUpdate) { try { activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.gms"))); } catch (android.content.ActivityNotFoundException anfe) { activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse( "http://play.google.com/store/apps/details?id=appPackageName"))); } } } }); AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); } callbackContext.error("Google Play Services is not available."); return; } // Check the API key ApplicationInfo appliInfo = null; try { appliInfo = activity.getPackageManager().getApplicationInfo(activity.getPackageName(), PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { } String API_KEY = appliInfo.metaData.getString("com.google.android.maps.v2.API_KEY"); if ("API_KEY_FOR_ANDROID".equals(API_KEY)) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity); alertDialogBuilder.setMessage( "Please replace 'API_KEY_FOR_ANDROID' in the platforms/android/AndroidManifest.xml with your API Key!") .setCancelable(false).setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); } // ------------------------------ // Initialize Google Maps SDK // ------------------------------ try { MapsInitializer.initialize(activity); } catch (Exception e) { e.printStackTrace(); callbackContext.error(e.getMessage()); return; } GoogleMapOptions options = new GoogleMapOptions(); JSONObject params = args.getJSONObject(0); //background color if (params.has("backgroundColor")) { JSONArray rgba = params.getJSONArray("backgroundColor"); int backgroundColor = Color.WHITE; if (rgba != null && rgba.length() == 4) { try { backgroundColor = PluginUtil.parsePluginColor(rgba); this.mPluginLayout.setBackgroundColor(backgroundColor); } catch (JSONException e) { } } } //controls if (params.has("controls")) { JSONObject controls = params.getJSONObject("controls"); if (controls.has("compass")) { options.compassEnabled(controls.getBoolean("compass")); } if (controls.has("zoom")) { options.zoomControlsEnabled(controls.getBoolean("zoom")); } } //gestures if (params.has("gestures")) { JSONObject gestures = params.getJSONObject("gestures"); if (gestures.has("tilt")) { options.tiltGesturesEnabled(gestures.getBoolean("tilt")); } if (gestures.has("scroll")) { options.scrollGesturesEnabled(gestures.getBoolean("scroll")); } if (gestures.has("rotate")) { options.rotateGesturesEnabled(gestures.getBoolean("rotate")); } if (gestures.has("zoom")) { options.zoomGesturesEnabled(gestures.getBoolean("zoom")); } } // map type if (params.has("mapType")) { String typeStr = params.getString("mapType"); int mapTypeId = -1; mapTypeId = typeStr.equals("MAP_TYPE_NORMAL") ? GoogleMap.MAP_TYPE_NORMAL : mapTypeId; mapTypeId = typeStr.equals("MAP_TYPE_HYBRID") ? GoogleMap.MAP_TYPE_HYBRID : mapTypeId; mapTypeId = typeStr.equals("MAP_TYPE_SATELLITE") ? GoogleMap.MAP_TYPE_SATELLITE : mapTypeId; mapTypeId = typeStr.equals("MAP_TYPE_TERRAIN") ? GoogleMap.MAP_TYPE_TERRAIN : mapTypeId; mapTypeId = typeStr.equals("MAP_TYPE_NONE") ? GoogleMap.MAP_TYPE_NONE : mapTypeId; if (mapTypeId != -1) { options.mapType(mapTypeId); } } // initial camera position if (params.has("camera")) { JSONObject camera = params.getJSONObject("camera"); Builder builder = CameraPosition.builder(); if (camera.has("bearing")) { builder.bearing((float) camera.getDouble("bearing")); } if (camera.has("latLng")) { JSONObject latLng = camera.getJSONObject("latLng"); builder.target(new LatLng(latLng.getDouble("lat"), latLng.getDouble("lng"))); } if (camera.has("tilt")) { builder.tilt((float) camera.getDouble("tilt")); } if (camera.has("zoom")) { builder.zoom((float) camera.getDouble("zoom")); } options.camera(builder.build()); } mapView = new MapView(activity, options); mapView.onCreate(null); mapView.onResume(); map = mapView.getMap(); //controls if (params.has("controls")) { JSONObject controls = params.getJSONObject("controls"); if (controls.has("myLocationButton")) { Boolean isEnabled = controls.getBoolean("myLocationButton"); map.setMyLocationEnabled(isEnabled); map.getUiSettings().setMyLocationButtonEnabled(isEnabled); } if (controls.has("indoorPicker")) { Boolean isEnabled = controls.getBoolean("indoorPicker"); map.setIndoorEnabled(isEnabled); } } // Set event listener map.setOnCameraChangeListener(this); map.setOnInfoWindowClickListener(this); map.setOnMapClickListener(this); map.setOnMapLoadedCallback(this); map.setOnMapLongClickListener(this); map.setOnMarkerClickListener(this); map.setOnMarkerDragListener(this); map.setOnMyLocationButtonClickListener(this); // Load PluginMap class this.loadPlugin("Map"); //Custom info window map.setInfoWindowAdapter(this); callbackContext.success(); // ------------------------------ // Embed the map if a container is specified. // ------------------------------ if (args.length() == 3) { this.mapDivLayoutJSON = args.getJSONObject(1); mPluginLayout.attachMyView(mapView); this.resizeMap(args, callbackContext); } }
From source file:com.zegoggles.smssync.PrefStore.java
static boolean isOldSmsBackupInstalled(Context context) { try {/*w w w. j a v a 2s .com*/ context.getPackageManager().getPackageInfo("tv.studer.smssync", android.content.pm.PackageManager.GET_META_DATA); return true; } catch (android.content.pm.PackageManager.NameNotFoundException e) { return false; } }
From source file:com.tealeaf.TeaLeaf.java
private void setFullscreenFlag() { try {//from w w w.j a v a2 s . com Bundle metaData = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA).metaData; isFullScreen = metaData.getBoolean("fullscreen", true); } catch (NameNotFoundException e) { logger.log(e); //Default to fullscreen mode. isFullScreen = true; } }
From source file:com.linkbubble.Settings.java
private boolean doesPackageExist(PackageManager pm, String targetPackage) { try {/*from w w w . j a va 2s. co m*/ PackageInfo info = pm.getPackageInfo(targetPackage, PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { return false; } return true; }
From source file:com.achep.base.ui.activities.SettingsActivity.java
private void getMetaData() { try {/*from w ww. ja v a2 s . c o m*/ ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); if (ai == null || ai.metaData == null) return; mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS); } catch (NameNotFoundException nnfe) { // No recovery Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString()); } }
From source file:com.tealeaf.TeaLeaf.java
private String findAppID() { String appid = getIntent().getStringExtra("appid"); if (appid != null) { return appid; }//from w ww.j a v a 2 s . c o m // FIXME HACK: find a better way to determine the appID try { Bundle metaData = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA).metaData; return metaData.containsKey("appID") ? metaData.get("appID").toString() : "tealeaf"; } catch (NameNotFoundException e) { logger.log(e); return "tealeaf"; } }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
public void onCreate(Bundle savedInstanceState) { Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler()); if (getPreferences().getBoolean("global", "pref_fullscreen", false)) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); IS_FULL_SCREEN = true;/*from w ww . j av a2 s. c o m*/ } //else getWindow().addFlags(WindowManager.LayoutParams.FLAG else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); IS_FULL_SCREEN = false; } IS_KEYBOARD_AVAILABLE = getContext().getResources() .getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY; loadPreferences(); if (getPreferences().getBoolean("global", "pref_hardware_accel", true) && !BEFORE_HONEYCOMB) getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); //mActionBarHelper = ActionBarHelper.createInstance(this); //mActionBarHelper.onCreate(savedInstanceState); if (BEFORE_HONEYCOMB) { requestWindowFeature(Window.FEATURE_NO_TITLE); USE_ACTION_BAR = false; //} else if(isGTV()) { // USE_ACTION_BAR = false; // mBar = (LeftNavBarService.instance()).getLeftNavBar(this); } else if (!BEFORE_HONEYCOMB) { requestWindowFeature(Window.FEATURE_ACTION_BAR); USE_ACTION_BAR = true; mBar = getActionBar(); } if (mBar != null) { if (Build.VERSION.SDK_INT >= 14) mBar.setHomeButtonEnabled(true); mBar.setDisplayUseLogoEnabled(true); try { mBar.setCustomView(R.layout.title_bar); mBar.setDisplayShowCustomEnabled(true); mBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); //ViewGroup cv = (ViewGroup)ab.getCustomView(); //if(cv.findViewById(R.id.title_paste) != null) // cv.removeView(cv.findViewById(R.id.title_paste)); //ab.getCustomView().findViewById(R.id.title_icon).setVisibility(View.GONE); } catch (InflateException e) { Logger.LogWarning("Couldn't set up ActionBar custom view", e); } } else USE_ACTION_BAR = false; OpenFile.setTempFileRoot(new OpenFile(getFilesDir()).getChild("temp")); setupLoggingDb(); handleExceptionHandler(); getMimeTypes(); setupFilesDb(); super.onCreate(savedInstanceState); setContentView(R.layout.main_fragments); getWindow().setBackgroundDrawableResource(R.drawable.background_holo_dark); try { upgradeViewSettings(); } catch (Exception e) { } //try { showWarnings(); //} catch(Exception e) { } mEvHandler.setUpdateListener(this); getClipboard().setClipboardUpdateListener(this); try { /* Signature[] sigs = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES).signatures; for(Signature sig : sigs) if(sig.toCharsString().indexOf("4465627567") > -1) // check for "Debug" in signature IS_DEBUG_BUILD = true; */ if (IS_DEBUG_BUILD) IS_DEBUG_BUILD = (getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA).applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE; if (isBlackBerry()) IS_DEBUG_BUILD = false; } catch (NameNotFoundException e1) { } handleNetworking(); refreshCursors(); checkWelcome(); checkRoot(); if (!BEFORE_HONEYCOMB) { boolean show_underline = true; if (Build.VERSION.SDK_INT < 14) show_underline = isGTV(); else if (getResources().getBoolean(R.bool.large)) // ICS+ tablets show_underline = false; if (Build.VERSION.SDK_INT > 13 && !getResources().getBoolean(R.bool.large)) show_underline = true; View tu = findViewById(R.id.title_underline); if (tu != null && !show_underline) { getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_shadow)); tu.setVisibility(View.GONE); } //if(USE_ACTION_BAR) // setViewVisibility(false, false, R.id.title_bar, R.id.title_underline, R.id.title_underline_2); } if (BEFORE_HONEYCOMB || !USE_ACTION_BAR) ViewUtils.inflateView(this, R.id.title_stub); if (BEFORE_HONEYCOMB) ViewUtils.inflateView(this, R.id.base_stub); setViewVisibility(false, false, R.id.title_paste, R.id.title_ops, R.id.title_log); setOnClicks(R.id.title_ops, //R.id.menu_global_ops_icon, R.id.menu_global_ops_text, R.id.title_log, R.id.title_icon, R.id.menu_more, R.id.title_paste_icon //,R.id.title_sort, R.id.title_view, R.id.title_up ); checkTitleSeparator(); IconContextMenu.clearInstances(); if (findViewById(R.id.list_frag) == null) mSinglePane = true; else if (findViewById(R.id.list_frag).getVisibility() == View.GONE) mSinglePane = true; Logger.LogDebug("Looking for path"); OpenPath path = mLastPath; if (savedInstanceState == null || path == null) { String start = getPreferences().getString("global", "pref_start", "External"); if (savedInstanceState != null && savedInstanceState.containsKey("last") && !savedInstanceState.getString("last").equals("")) start = savedInstanceState.getString("last"); path = FileManager.getOpenCache(start, this); } if (path == null) path = OpenFile.getExternalMemoryDrive(true); if (FileManager.checkForNoMedia(path)) showToast(R.string.s_error_no_media, Toast.LENGTH_LONG); mLastPath = path; boolean bAddToStack = true; if (findViewById(R.id.content_pager_frame_stub) != null) ((ViewStub) findViewById(R.id.content_pager_frame_stub)).inflate(); Logger.LogDebug("Pager inflated"); if (fragmentManager == null) { fragmentManager = getSupportFragmentManager(); fragmentManager.addOnBackStackChangedListener(this); } mLogFragment = new LogViewerFragment(); FragmentTransaction ft = fragmentManager.beginTransaction(); Logger.LogDebug("Creating with " + path.getPath()); if (path instanceof OpenFile) new PeekAtGrandKidsTask().execute((OpenFile) path); initPager(); if (handleIntent(getIntent())) { path = mLastPath = null; bAddToStack = false; } if (mViewPager != null && mViewPagerAdapter != null && path != null) { //mViewPagerAdapter.add(mContentFragment); mLastPath = null; changePath(path, bAddToStack, true); setCurrentItem(mViewPagerAdapter.getCount() - 1, false); restoreOpenedEditors(); } else Logger.LogWarning("Nothing to show?!"); ft.commit(); invalidateOptionsMenu(); initBookmarkDropdown(); handleMediaReceiver(); if (!getPreferences().getBoolean("global", "pref_splash", false)) showSplashIntent(this, getPreferences().getString("global", "pref_start", "Internal")); }
From source file:org.junit4android.JunitTestRunnerActivity.java
/** * @return//from w w w . j a v a 2 s . c o m */ private Bundle getActivityMetadata() { try { ActivityInfo activityInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); return activityInfo.metaData; } catch (NameNotFoundException e) { throw new RuntimeException(e); } }