List of usage examples for android.content.pm PackageManager GET_CONFIGURATIONS
int GET_CONFIGURATIONS
To view the source code for android.content.pm PackageManager GET_CONFIGURATIONS.
Click Source Link
From source file:net.basilwang.StaticAttachmentActivity.java
private Double getVersionName() { try {//w w w. j a v a2 s . co m return Double .valueOf(getPackageManager().getPackageInfo( "net.basilwang", PackageManager.GET_CONFIGURATIONS).versionName); } catch (NameNotFoundException e) { e.printStackTrace(); return 1.00; } }
From source file:com.liato.bankdroid.Helpers.java
public static String getAppUserAgentString(Context context) { if (USER_AGENT != null) return USER_AGENT; String appName = context.getResources().getString(R.string.app_name); String appVersion = ""; int height = 0; int width = 0; DisplayMetrics display = context.getResources().getDisplayMetrics(); Configuration config = context.getResources().getConfiguration(); // Always send screen dimension for portrait mode if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { height = display.widthPixels;//ww w . j ava 2 s . co m width = display.heightPixels; } else { width = display.widthPixels; height = display.heightPixels; } try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_CONFIGURATIONS); appVersion = packageInfo.versionName; } catch (PackageManager.NameNotFoundException ignore) { // this should never happen, we are looking up ourself } // Tries to conform to default android UA string without the Safari / webkit noise, plus adds the screen dimensions USER_AGENT = String.format( "%1$s/%2$s (%3$s; U; Android %4$s; %5$s-%6$s; %12$s Build/%7$s; %8$s) %9$dX%10$d %11$s %12$s", appName, appVersion, System.getProperty("os.name", "Linux"), Build.VERSION.RELEASE, config.locale.getLanguage().toLowerCase(), config.locale.getCountry().toLowerCase(), Build.ID, Build.BRAND, width, height, Build.MANUFACTURER, Build.MODEL); return USER_AGENT; }
From source file:org.zywx.wbpalmstar.platform.push.PushService.java
private void runningNotification(JSONObject text) throws JSONException { String pushMessage = text.toString();// ?? // ?// w ww . j a va 2s . c o m String tickerText = text.getString("title"); String value = text.getString("body"); String packg = getPackageName(); String widgetName = null; PackageManager pm = getPackageManager(); PackageInfo pinfo = null; try { pinfo = pm.getPackageInfo(packg, PackageManager.GET_CONFIGURATIONS); String appName = pinfo.applicationInfo.loadLabel(getPackageManager()).toString(); widgetName = appName; Editor editor = preferences.edit(); editor.putString("widgetName", widgetName); editor.commit(); } catch (Exception e) { e.printStackTrace(); } if (TextUtils.isEmpty(widgetName)) { widgetName = preferences.getString("widgetName", ""); } Intent intent = new Intent(PushRecieveMsgReceiver.ACTION_PUSH); intent.putExtra("data", value); intent.putExtra("title", tickerText); intent.putExtra("widgetName", widgetName); intent.setPackage(packg); intent.putExtra("message", pushMessage); sendBroadcast(intent);// try { PushReportAgent.reportPush(value, System.currentTimeMillis() + "", PushReportConstants.EVENT_TYPE_ARRIVED, softToken, this);// ?? } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.nullbyte.android.urllib.Urllib.java
private String createUserAgentString() { String appName = mContext.getString(R.string.app_name); String packageName = ""; String appVersion = ""; try {//ww w . ja v a 2 s.c o m PackageInfo packageInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), PackageManager.GET_CONFIGURATIONS); packageName = packageInfo.packageName; appVersion = packageInfo.versionName; } catch (PackageManager.NameNotFoundException ignore) { } Configuration config = mContext.getResources().getConfiguration(); return String.format("%1$s/%2$s (%3$s; U; Android %4$s; %5$s-%6$s; %10$s Build/%7$s; %8$s) %9$s %10$s", appName, appVersion, System.getProperty("os.name", "Linux"), Build.VERSION.RELEASE, config.locale.getLanguage().toLowerCase(), config.locale.getCountry().toLowerCase(), Build.ID, Build.BRAND, Build.MANUFACTURER, Build.MODEL); }
From source file:android.content.pm.PackageParser.java
public static PackageInfo generatePackageInfo(PackageParser.Package p, int gids[], int flags, long firstInstallTime, long lastUpdateTime, Set<String> grantedPermissions, PackageUserState state, int userId) { if (!checkUseInstalledOrHidden(flags, state)) { return null; }/*from w w w . ja v a 2s. c o m*/ PackageInfo pi = new PackageInfo(); pi.packageName = p.packageName; pi.splitNames = p.splitNames; pi.versionCode = p.mVersionCode; pi.baseRevisionCode = p.baseRevisionCode; pi.splitRevisionCodes = p.splitRevisionCodes; pi.versionName = p.mVersionName; pi.sharedUserId = p.mSharedUserId; pi.sharedUserLabel = p.mSharedUserLabel; pi.applicationInfo = generateApplicationInfo(p, flags, state, userId); pi.installLocation = p.installLocation; pi.coreApp = p.coreApp; if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 || (pi.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) { pi.requiredForAllUsers = p.mRequiredForAllUsers; } pi.restrictedAccountType = p.mRestrictedAccountType; pi.requiredAccountType = p.mRequiredAccountType; pi.overlayTarget = p.mOverlayTarget; pi.firstInstallTime = firstInstallTime; pi.lastUpdateTime = lastUpdateTime; if ((flags & PackageManager.GET_GIDS) != 0) { pi.gids = gids; } if ((flags & PackageManager.GET_CONFIGURATIONS) != 0) { int N = p.configPreferences != null ? p.configPreferences.size() : 0; if (N > 0) { pi.configPreferences = new ConfigurationInfo[N]; p.configPreferences.toArray(pi.configPreferences); } N = p.reqFeatures != null ? p.reqFeatures.size() : 0; if (N > 0) { pi.reqFeatures = new FeatureInfo[N]; p.reqFeatures.toArray(pi.reqFeatures); } N = p.featureGroups != null ? p.featureGroups.size() : 0; if (N > 0) { pi.featureGroups = new FeatureGroupInfo[N]; p.featureGroups.toArray(pi.featureGroups); } } if ((flags & PackageManager.GET_ACTIVITIES) != 0) { int N = p.activities.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.activities = new ActivityInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.activities.get(i).info.enabled) num++; } pi.activities = new ActivityInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Activity activity = p.activities.get(i); if (activity.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.activities[j++] = generateActivityInfo(p.activities.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_RECEIVERS) != 0) { int N = p.receivers.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.receivers = new ActivityInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.receivers.get(i).info.enabled) num++; } pi.receivers = new ActivityInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Activity activity = p.receivers.get(i); if (activity.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.receivers[j++] = generateActivityInfo(p.receivers.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_SERVICES) != 0) { int N = p.services.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.services = new ServiceInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.services.get(i).info.enabled) num++; } pi.services = new ServiceInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Service service = p.services.get(i); if (service.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.services[j++] = generateServiceInfo(p.services.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_PROVIDERS) != 0) { int N = p.providers.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.providers = new ProviderInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.providers.get(i).info.enabled) num++; } pi.providers = new ProviderInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Provider provider = p.providers.get(i); if (provider.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.providers[j++] = generateProviderInfo(p.providers.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_INSTRUMENTATION) != 0) { int N = p.instrumentation.size(); if (N > 0) { pi.instrumentation = new InstrumentationInfo[N]; for (int i = 0; i < N; i++) { pi.instrumentation[i] = generateInstrumentationInfo(p.instrumentation.get(i), flags); } } } if ((flags & PackageManager.GET_PERMISSIONS) != 0) { int N = p.permissions.size(); if (N > 0) { pi.permissions = new PermissionInfo[N]; for (int i = 0; i < N; i++) { pi.permissions[i] = generatePermissionInfo(p.permissions.get(i), flags); } } N = p.requestedPermissions.size(); if (N > 0) { pi.requestedPermissions = new String[N]; pi.requestedPermissionsFlags = new int[N]; for (int i = 0; i < N; i++) { final String perm = p.requestedPermissions.get(i); pi.requestedPermissions[i] = perm; // The notion of required permissions is deprecated but for compatibility. pi.requestedPermissionsFlags[i] |= PackageInfo.REQUESTED_PERMISSION_REQUIRED; if (grantedPermissions != null && grantedPermissions.contains(perm)) { pi.requestedPermissionsFlags[i] |= PackageInfo.REQUESTED_PERMISSION_GRANTED; } } } } if ((flags & PackageManager.GET_SIGNATURES) != 0) { int N = (p.mSignatures != null) ? p.mSignatures.length : 0; if (N > 0) { pi.signatures = new Signature[N]; System.arraycopy(p.mSignatures, 0, pi.signatures, 0, N); } } return pi; }