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.nikola.despotoski.drawerlayoutedgetoggle.DrawerLayoutEdgeToggle.java
private int iterateAttributesForActionBarSherlock() { PackageInfo packageInfo;//from w w w. j a v a2s . c o m try { packageInfo = mActivity.getPackageManager().getPackageInfo(mActivity.getPackageName(), PackageManager.GET_META_DATA); int themeId = packageInfo.applicationInfo.theme; TypedArray themeAttributes = mActivity.getResources().obtainTypedArray(themeId); for (int i = 0; i < themeAttributes.length(); i++) { try { TypedValue v = new TypedValue(); themeAttributes.getValue(i, v); String attName = mActivity.getResources().getResourceEntryName(v.resourceId); if (attName != null && attName.contains("actionbarsherlock") && attName.contains("actionBarSize")) { return v.data; } } catch (Exception e) { Log.e("ResourceNotFound", "" + e.getMessage()); } } themeAttributes.recycle(); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 0; }
From source file:com.cw.litenote.config.Config.java
void aboutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); PackageInfo pInfo = null;/*from w w w .j a va 2 s.c o m*/ String version_name = "NA"; int version_code = 0; try { Context context = DrawerActivity.mDrawerActivity; pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { e.printStackTrace(); } if (pInfo != null) { version_name = pInfo.versionName; version_code = pInfo.versionCode; } String msgStr = getActivity().getResources().getString(R.string.config_about_version_name) + " : " + version_name + "\n" + getActivity().getResources().getString(R.string.config_about_version_code) + " : " + version_code + "\n\n" + getActivity().getResources().getString(R.string.EULA_string); builder.setTitle(R.string.config_about).setMessage(msgStr).setNegativeButton(R.string.btn_Cancel, null) .show(); }
From source file:com.noshufou.android.su.util.Util.java
public static VersionInfo getSuperuserVersionInfo(Context context) { VersionInfo info = new VersionInfo(); PackageManager pm = context.getPackageManager(); try {//from w w w .jav a2 s.c om PackageInfo pInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_META_DATA); info.version = pInfo.versionName; info.versionCode = pInfo.versionCode; } catch (NameNotFoundException e) { Log.e(TAG, "Superuser is not installed?", e); } return info; }
From source file:com.shafiq.mytwittle.App.java
@Override public void onCreate() { Log.d("mytwittle url fetch", "*** New run"); Log.d("AsyncTaskEx", "*** New run"); Log.d("StatusCache", "*** New run"); super.onCreate(); java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel(java.util.logging.Level.FINEST); java.util.logging.Logger.getLogger("org.apache.http.headers").setLevel(java.util.logging.Level.FINEST); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.headers", "debug"); try {//from w w w . j a v a2 s. c o m PackageManager packageManager = getPackageManager(); PackageInfo packageInfo = packageManager.getPackageInfo(getPackageName(), 0); mAppVersionNumber = packageInfo.versionCode; mAppVersionName = packageInfo.versionName; List<ApplicationInfo> apps = packageManager.getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo app : apps) { if (app.packageName != null && app.packageName.equalsIgnoreCase("com.shafiq.actionlauncher.pro")) { // mActionLauncherInstalled = true; break; } } } catch (NameNotFoundException e) { e.printStackTrace(); } mPreferences = PreferenceManager.getDefaultSharedPreferences(this); mPreferences.edit().putInt(SHARED_PREFERENCES_KEY_VERSION, Constant.SHARED_PREFERENCES_VERSION); mAccounts = new ArrayList<AccountDescriptor>(); updateTwitterAccountCount(); SocialNetConstant.Type socialNetType = SocialNetConstant.Type.Twitter; AccountDescriptor currentAccountDescriptor = getCurrentAccount(); if (currentAccountDescriptor != null) { socialNetType = currentAccountDescriptor.getSocialNetType(); if (socialNetType == null) { socialNetType = SocialNetConstant.Type.Twitter; } TwitterManager.initModule(socialNetType, socialNetType == SocialNetConstant.Type.Twitter ? Constant.TWITTER_CONSUMER_KEY : Constant.APPDOTNET_CONSUMER_KEY, socialNetType == SocialNetConstant.Type.Twitter ? Constant.TWITTER_CONSUMER_SECRET : Constant.TWITTER_CONSUMER_SECRET, currentAccountDescriptor.getOAuthToken(), currentAccountDescriptor.getOAuthSecret(), currentAccountDescriptor.getAccountKey(), mConnectionStatusCallbacks); } else { TwitterManager.initModule(SocialNetConstant.Type.Twitter, Constant.TWITTER_CONSUMER_KEY, Constant.TWITTER_CONSUMER_SECRET, null, null, null, mConnectionStatusCallbacks); } setLaneDefinitions(socialNetType); AppSettings.initModule(this); NotificationHelper.initModule(); }
From source file:com.imagine.BaseActivity.java
String libDir() { ActivityInfo ai;/*from w ww. j a va2s.c o m*/ try { ai = getPackageManager().getActivityInfo(getIntent().getComponent(), PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException("Error getting activity info", e); } return ai.applicationInfo.nativeLibraryDir; }
From source file:com.google.android.apps.muzei.settings.ChooseSourceFragment.java
public void updateSources() { mSelectedSource = null;/*from ww w. ja va 2s .c o m*/ Intent queryIntent = new Intent(ACTION_MUZEI_ART_SOURCE); PackageManager pm = getContext().getPackageManager(); mSources.clear(); List<ResolveInfo> resolveInfos = pm.queryIntentServices(queryIntent, PackageManager.GET_META_DATA); for (ResolveInfo ri : resolveInfos) { Source source = new Source(); source.label = ri.loadLabel(pm).toString(); source.icon = new BitmapDrawable(getResources(), generateSourceImage(ri.loadIcon(pm))); source.targetSdkVersion = ri.serviceInfo.applicationInfo.targetSdkVersion; source.componentName = new ComponentName(ri.serviceInfo.packageName, ri.serviceInfo.name); if (ri.serviceInfo.descriptionRes != 0) { try { Context packageContext = getContext() .createPackageContext(source.componentName.getPackageName(), 0); Resources packageRes = packageContext.getResources(); source.description = packageRes.getString(ri.serviceInfo.descriptionRes); } catch (PackageManager.NameNotFoundException | Resources.NotFoundException e) { Log.e(TAG, "Can't read package resources for source " + source.componentName); } } Bundle metaData = ri.serviceInfo.metaData; source.color = Color.WHITE; if (metaData != null) { String settingsActivity = metaData.getString("settingsActivity"); if (!TextUtils.isEmpty(settingsActivity)) { source.settingsActivity = ComponentName .unflattenFromString(ri.serviceInfo.packageName + "/" + settingsActivity); } String setupActivity = metaData.getString("setupActivity"); if (!TextUtils.isEmpty(setupActivity)) { source.setupActivity = ComponentName .unflattenFromString(ri.serviceInfo.packageName + "/" + setupActivity); } source.color = metaData.getInt("color", source.color); try { float[] hsv = new float[3]; Color.colorToHSV(source.color, hsv); boolean adjust = false; if (hsv[2] < 0.8f) { hsv[2] = 0.8f; adjust = true; } if (hsv[1] > 0.4f) { hsv[1] = 0.4f; adjust = true; } if (adjust) { source.color = Color.HSVToColor(hsv); } if (Color.alpha(source.color) != 255) { source.color = Color.argb(255, Color.red(source.color), Color.green(source.color), Color.blue(source.color)); } } catch (IllegalArgumentException ignored) { } } mSources.add(source); } final String appPackage = getContext().getPackageName(); Collections.sort(mSources, new Comparator<Source>() { @Override public int compare(Source s1, Source s2) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { boolean target1IsO = s1.targetSdkVersion >= Build.VERSION_CODES.O; boolean target2IsO = s2.targetSdkVersion >= Build.VERSION_CODES.O; if (target1IsO && !target2IsO) { return 1; } else if (!target1IsO && target2IsO) { return -1; } } String pn1 = s1.componentName.getPackageName(); String pn2 = s2.componentName.getPackageName(); if (!pn1.equals(pn2)) { if (appPackage.equals(pn1)) { return -1; } else if (appPackage.equals(pn2)) { return 1; } } return s1.label.compareTo(s2.label); } }); redrawSources(); }
From source file:com.haibison.android.lockpattern.LockPatternFragment.java
/** * Loads settings, either from manifest or {@link Settings}. *//*from ww w . ja v a 2 s.c om*/ private void loadSettings() { Bundle metaData = null; try { metaData = fa.getPackageManager().getActivityInfo(fa.getComponentName(), PackageManager.GET_META_DATA).metaData; } catch (NameNotFoundException e) { /* * Never catch getActivity(). */ e.printStackTrace(); } if (metaData != null && metaData.containsKey(METADATA_MIN_WIRED_DOTS)) mMinWiredDots = Settings.Display.validateMinWiredDots(getActivity(), metaData.getInt(METADATA_MIN_WIRED_DOTS)); else mMinWiredDots = Settings.Display.getMinWiredDots(getActivity()); if (metaData != null && metaData.containsKey(METADATA_MAX_RETRIES)) mMaxRetries = Settings.Display.validateMaxRetries(getActivity(), metaData.getInt(METADATA_MAX_RETRIES)); else mMaxRetries = Settings.Display.getMaxRetries(getActivity()); if (metaData != null && metaData.containsKey(METADATA_AUTO_SAVE_PATTERN)) mAutoSave = metaData.getBoolean(METADATA_AUTO_SAVE_PATTERN); else mAutoSave = Settings.Security.isAutoSavePattern(getActivity()); if (metaData != null && metaData.containsKey(METADATA_CAPTCHA_WIRED_DOTS)) mCaptchaWiredDots = Settings.Display.validateCaptchaWiredDots(getActivity(), metaData.getInt(METADATA_CAPTCHA_WIRED_DOTS)); else mCaptchaWiredDots = Settings.Display.getCaptchaWiredDots(getActivity()); if (metaData != null && metaData.containsKey(METADATA_STEALTH_MODE)) mStealthMode = metaData.getBoolean(METADATA_STEALTH_MODE); else mStealthMode = Settings.Display.isStealthMode(getActivity()); /* * Encrypter. */ char[] encrypterClass; if (metaData != null && metaData.containsKey(METADATA_ENCRYPTER_CLASS)) encrypterClass = metaData.getString(METADATA_ENCRYPTER_CLASS).toCharArray(); else encrypterClass = Settings.Security.getEncrypterClass(getActivity()); if (encrypterClass != null) { try { mEncrypter = (IEncrypter) Class.forName(new String(encrypterClass), false, fa.getClassLoader()) .newInstance(); } catch (Throwable t) { throw new InvalidEncrypterException(); } } }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * gets the application icon.//from ww w .ja v a 2s.c o m * * @param context * @param packageName * @return */ public static Drawable appInfo_getIconFromPackageName(Context context, String packageName) { PackageManager pm = context.getPackageManager(); ApplicationInfo appInfo = null; try { appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { return null; } return appInfo.loadIcon(pm); }
From source file:com.samsung.multiwindow.MultiWindow.java
/** * Get the MultiWindow enabled applications and activity names * // www . j a v a 2s . c o m * @param windowType * The window type freestyle or splitstyle. * @param callbackContext * The callback id used when calling back into JavaScript. * */ private void getMultiWindowApps(final String windowType, final CallbackContext callbackContext) throws JSONException { if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) { Log.d(TAG, "Inside getMultiWindowApps"); } cordova.getThreadPool().execute(new Runnable() { public void run() { JSONArray multiWindowApps = new JSONArray(); Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> resolveInfos = cordova.getActivity().getPackageManager().queryIntentActivities( intent, PackageManager.GET_RESOLVED_FILTER | PackageManager.GET_META_DATA); try { // Get the multiwindow enabled applications int index = 0; for (ResolveInfo r : resolveInfos) { if (r.activityInfo != null && r.activityInfo.applicationInfo.metaData != null) { if (r.activityInfo.applicationInfo.metaData .getBoolean("com.sec.android.support.multiwindow") || r.activityInfo.applicationInfo.metaData .getBoolean("com.samsung.android.sdk.multiwindow.enable")) { JSONObject appInfo = new JSONObject(); boolean bUnSupportedMultiWinodw = false; if (windowType.equalsIgnoreCase("splitstyle")) { if (r.activityInfo.metaData != null) { String activityWindowStyle = r.activityInfo.metaData .getString("com.sec.android.multiwindow.activity.STYLE"); if (activityWindowStyle != null) { ArrayList<String> activityWindowStyles = new ArrayList<String>( Arrays.asList(activityWindowStyle.split("\\|"))); if (!activityWindowStyles.isEmpty()) { if (activityWindowStyles.contains("fullscreenOnly")) { bUnSupportedMultiWinodw = true; } } } } } if (!bUnSupportedMultiWinodw || !windowType.equalsIgnoreCase("splitstyle")) { appInfo.put("packageName", r.activityInfo.applicationInfo.packageName); appInfo.put("activity", r.activityInfo.name); multiWindowApps.put(index++, appInfo); } } } } callbackContext.success(multiWindowApps); } catch (Exception e) { callbackContext.error(e.getMessage()); } } }); }
From source file:com.tweetlanes.android.core.App.java
@Override public void onCreate() { Log.d("tweetlanes url fetch", "*** New run"); Log.d("AsyncTaskEx", "*** New run"); Log.d("StatusCache", "*** New run"); super.onCreate(); java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel(java.util.logging.Level.FINEST); java.util.logging.Logger.getLogger("org.apache.http.headers").setLevel(java.util.logging.Level.FINEST); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "debug"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.headers", "debug"); try {/*from www . j ava 2 s .co m*/ PackageManager packageManager = getPackageManager(); PackageInfo packageInfo = packageManager.getPackageInfo(getPackageName(), 0); mAppVersionName = packageInfo.versionName; List<ApplicationInfo> apps = packageManager.getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo app : apps) { if (app.packageName != null && app.packageName.equalsIgnoreCase("com.chrislacy.actionlauncher.pro")) { mActionLauncherInstalled = true; break; } } } catch (NameNotFoundException e) { e.printStackTrace(); } mPreferences = PreferenceManager.getDefaultSharedPreferences(this); mPreferences.edit().putInt(SharedPreferencesConstants.VERSION, Constant.SHARED_PREFERENCES_VERSION); mAccounts = new ArrayList<AccountDescriptor>(); updateTwitterAccountCount(); SocialNetConstant.Type socialNetType = SocialNetConstant.Type.Twitter; AccountDescriptor currentAccountDescriptor = getCurrentAccount(); if (currentAccountDescriptor != null) { socialNetType = currentAccountDescriptor.getSocialNetType(); if (socialNetType == null) { socialNetType = SocialNetConstant.Type.Twitter; } TwitterManager.initModule(socialNetType, socialNetType == SocialNetConstant.Type.Twitter ? ConsumerKeyConstants.TWITTER_CONSUMER_KEY : ConsumerKeyConstants.APPDOTNET_CONSUMER_KEY, socialNetType == SocialNetConstant.Type.Twitter ? ConsumerKeyConstants.TWITTER_CONSUMER_SECRET : ConsumerKeyConstants.TWITTER_CONSUMER_SECRET, currentAccountDescriptor.getOAuthToken(), currentAccountDescriptor.getOAuthSecret(), currentAccountDescriptor.getAccountKey(), mConnectionStatusCallbacks); } else { TwitterManager.initModule(SocialNetConstant.Type.Twitter, ConsumerKeyConstants.TWITTER_CONSUMER_KEY, ConsumerKeyConstants.TWITTER_CONSUMER_SECRET, null, null, null, mConnectionStatusCallbacks); } setLaneDefinitions(socialNetType); AppSettings.initModule(this); }