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.github.michalbednarski.intentslab.providerlab.ProviderInfoFragment.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) private void fillProviderInfo() throws PackageManager.NameNotFoundException { mProviderInfo = getActivity().getPackageManager().getProviderInfo( new ComponentName(mPackageName, mComponentName), PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_META_DATA | PackageManager.GET_URI_PERMISSION_PATTERNS); }
From source file:com.framgia.android.emulator.EmulatorDetector.java
private boolean checkPackageName() { final PackageManager packageManager = mContext.getPackageManager(); List<ApplicationInfo> packages = packageManager.getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo packageInfo : packages) { String packageName = packageInfo.packageName; boolean isEmulator = mListPackageName.contains(packageName); if (isEmulator) { log("Detected " + packageName); return true; }/* ww w . j ava 2 s . com*/ } return false; }
From source file:com.dnielfe.manager.AppManager.java
private void get_downloaded_apps() { List<ApplicationInfo> all_apps = pm.getInstalledApplications(PackageManager.GET_META_DATA); if (!mAppList.isEmpty()) mAppList.clear();//ww w .j av a 2s .c o m for (ApplicationInfo appInfo : all_apps) { if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0 && (appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0 && appInfo.flags != 0) mAppList.add(appInfo); } // Sorting ListView showing Installed Applications Collections.sort(mAppList, new ApplicationInfo.DisplayNameComparator(pm)); // update UI initActionBar(); mAdapter.notifyDataSetChanged(); }
From source file:com.oasis.sdk.activity.GooglePlayBillingActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_pay_google")); myHandler = new MyHandler(this); /* base64EncodedPublicKey should be YOUR APPLICATION'S PUBLIC KEY * (that you got from the Google Play developer console). This is not your * developer public key, it's the *app-specific* public key. */* ww w . ja v a 2 s . co m*/ * Instead of just storing the entire literal string here embedded in the * program, construct the key at runtime from pieces or * use bit manipulation (for example, XOR with some other string) to hide * the actual key. The key itself is not secret information, but we don't * want to make it easy for an attacker to replace the public key with one * of their own and then fake messages from the server. */ // String base64EncodedPublicKey = "CONSTRUCT_YOUR_KEY_AND_PLACE_IT_HERE"; if (TextUtils.isEmpty(base64EncodedPublicKey)) { ApplicationInfo appInfo; try { appInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); base64EncodedPublicKey = appInfo.metaData.getString("com.googleplay.ApplicationId"); } catch (NameNotFoundException e) { BaseUtils.logDebug(TAG, "Please put your app's public key in AndroidManifest.xml."); } } if (TextUtils.isEmpty(base64EncodedPublicKey)) { BaseUtils.logError(TAG, "Please put your app's public key in AndroidManifest.xml."); complain("Please put your app's public key in AndroidManifest.xml."); return; } productID = getIntent().getStringExtra("inAppProductID"); ext = getIntent().getStringExtra("ext"); oasOrderid = getIntent().getStringExtra("oasOrderid"); if (TextUtils.isEmpty(productID)) { BaseUtils.logError(TAG, "Please put product id."); complain("Please put product id."); return; } if (SystemCache.userInfo == null || TextUtils.isEmpty(SystemCache.userInfo.serverID) || TextUtils.isEmpty(SystemCache.userInfo.roleID)) { BaseUtils.logError(TAG, "Please put game serverid or roleid."); complain("Please put game server id."); return; } // revenue = getRevenueAndCurrency();// ?productid????? // if(TextUtils.isEmpty(revenue)){ // BaseUtils.logError(TAG, "This product id does not exist, please contact customer support"); // setResult(OASISPlatformConstant.RESULT_EXCEPTION); // Message msg = new Message(); // msg.what = 0; // msg.obj = getResources().getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_2")); // myHandler.sendMessage(msg); // return; // } setWaitScreen(true); if (SystemCache.OASISSDK_ENVIRONMENT_SANDBOX) { initSandBox(); //1 ? ?? //2 ??? //3 ?? return; } // Create the helper, passing it our context and the public key to verify signatures with BaseUtils.logDebug(TAG, "Creating IAB helper."); mHelper = new IabHelper(this.getApplicationContext(), base64EncodedPublicKey); // enable debug logging (for a production application, you should set this to false). mHelper.enableDebugLogging(SystemCache.OASISSDK_ENVIRONMENT_SANDBOX); int isGoolgePlayAvail = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this.getApplicationContext()); if (isGoolgePlayAvail == ConnectionResult.SUCCESS) { // Start setup. This is asynchronous and the specified listener // will be called once setup completes. BaseUtils.logDebug(TAG, "Starting setup."); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (isPageClose()) { isPageCloseHandler(); return; } BaseUtils.logDebug(TAG, "Setup finished."); if (!result.isSuccess()) { // Oh noes, there was a problem. BaseUtils.logError(TAG, "Problem setting up in-app billing: " + IabHelper.getResponseDesc(result.getResponse())); Message msg = new Message(); msg.what = 0; msg.obj = getResources().getString( BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_1")); myHandler.sendMessage(msg); return; } // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) return; // IAB is fully set up. Now, Start purchase. try { oldOrderList = GoogleBillingUtils.getPurchasedList(); } catch (JSONException e) { e.printStackTrace(); } // queryInventory(); checkALLOrder(0); } }); } else { Dialog d = GooglePlayServicesUtil.getErrorDialog(isGoolgePlayAvail, this, RC_VERIFYGOOGLEPLAY); d.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { BaseUtils.logError(TAG, "GooglePlayServicesUtil.showErrorDialogFragment"); arg0.dismiss(); myHandler.sendEmptyMessageDelayed(-1, 500); } }); d.show(); } }
From source file:com.huison.DriverAssistant_Web.util.LoginHelper.java
private static String getChannel(Context context) { ApplicationInfo appInfo;//from w w w. j a v a2 s . c o m String value = null; try { appInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); value = appInfo.metaData.getString("UMENG_CHANNEL"); } catch (NameNotFoundException e) { } return value; }
From source file:com.scoreflex.ScoreflexGcmClient.java
/** * Start the registration process for GCM. * @param senderID The sender ID to register to. * @param context A valid context/*w w w .j av a 2 s .co m*/ */ @SuppressLint("NewApi") public static void registerForPushNotification(Context context) { String regid = getRegistrationId(context); String pushSenderId = null; try { ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Bundle bundle = ai.metaData; pushSenderId = bundle.getString("com.scoreflex.push.SenderId"); } catch (NameNotFoundException e) { Log.e("Scoreflex", "Could not get com.scoreflex.push.SenderId meta data from your manifest did you add : <meta-data android:name=\"com.scoreflex.push.SenderId\" android:value=\"@string/push_sender_id\"/>"); } catch (NullPointerException e) { Log.e("Scoreflex", "Could not get com.scoreflex.push.SenderId meta data from your manifest did you add : <meta-data android:name=\"com.scoreflex.push.SenderId\" android:value=\"@string/push_sender_id\"/>"); } if (pushSenderId == null) { return; } if (TextUtils.isEmpty(regid)) { registerInBackground(pushSenderId, context); } else { storeRegistrationIdToScoreflex(regid); } return; }
From source file:com.airbop.library.simple.CommonUtilities.java
public static AirBopManifestSettings loadDataFromManifest(Context application_context) { AirBopManifestSettings airbop_settings = new AirBopManifestSettings(); if (application_context != null) { //Log.v(TAG, "loadDataFromManifest: application_context != null"); ApplicationInfo ai;/*from www . j ava 2 s . com*/ try { ai = application_context.getPackageManager() .getApplicationInfo(application_context.getPackageName(), PackageManager.GET_META_DATA); if (ai != null) { //Log.v(TAG, "loadDataFromManifest: ai != null"); //Log.v(TAG, "application_context.getPackageName(): " // + application_context.getPackageName()); Bundle app_bundle = ai.metaData; if (app_bundle != null) { //Log.v(TAG, "app_bundle: "+ app_bundle); if (airbop_settings != null) { //Log.v(TAG, "app_bundle: airbop_settings != null"); airbop_settings.mGoogleProjectNumber = app_bundle .getString(AIRBOP_GOOGLE_PROJECT_NUMBER); //Log.v(TAG, "mGoogleProjectNumber: " + airbop_settings.mGoogleProjectNumber); airbop_settings.mAirBopAppkey = app_bundle.getString(AIRBOP_APP_KEY); //Log.v(TAG, "mAirBopAppkey: " + airbop_settings.mAirBopAppkey); airbop_settings.mAirBopAppSecret = app_bundle.getString(AIRBOP_APP_SECRET); //Log.v(TAG, "mAirBopAppSecret: " + airbop_settings.mAirBopAppSecret); airbop_settings.mUseLocation = app_bundle.getBoolean(AIRBOP_USE_LOCATION, false); //Log.v(TAG, "mUseLocation: " + airbop_settings.mUseLocation); airbop_settings.mDefaultNotificationTitle = app_bundle .getString(AIRBOP_DEFAULT_NOTIFICATION_TITLE); //Log.v(TAG, "mDefaultNotificationTitle: " + airbop_settings.mDefaultNotificationTitle); if (airbop_settings.mDefaultNotificationTitle == null) { airbop_settings.mDefaultNotificationTitle = ""; } airbop_settings.mNotificationIcon = app_bundle.getInt(AIRBOP_NOTIFICATION_ICON); //Log.v(TAG, "mNotificationIcon: " + airbop_settings.mNotificationIcon); airbop_settings.mDefaultNotificationClass = app_bundle .getString(AIRBOP_DEFAULT_NOTIFICATION_CLASS); //Log.v(TAG, "mDefaultNotificationClass: " + airbop_settings.mDefaultNotificationClass); airbop_settings.mDefaultNotificationHandling = app_bundle .getBoolean(AIRBOP_DEFAULT_NOTIFICATION_HANDLING, true); //Log.v(TAG, "mDefaultNotificationHandling: " + airbop_settings.mDefaultNotificationHandling); } } } } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return airbop_settings; }
From source file:com.github.michalbednarski.intentslab.providerlab.ProviderInfoFragment.java
private void fillProviderInfoLegacy() throws PackageManager.NameNotFoundException { PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(mPackageName, PackageManager.GET_PROVIDERS | PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_META_DATA | PackageManager.GET_URI_PERMISSION_PATTERNS); for (ProviderInfo provider : packageInfo.providers) { if (provider.name.equals(mComponentName)) { mProviderInfo = provider;/* w w w. jav a2s . c om*/ return; } } throw new PackageManager.NameNotFoundException("No such provider (manual search in PackageInfo)"); }
From source file:pffy.mobile.bran.BranActivity.java
private String getVersionInfo() { // Based on solution found here: // http://stackoverflow.com/a/2941199 PackageInfo info;//from w w w . j a v a2 s . c o m String str = ""; try { info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA); str += "v" + info.versionName + " (r" + info.versionCode + ")"; } catch (NameNotFoundException nnfe) { str += "No version info."; } str += CRLF + getString(R.string.msg_authors); return str; }
From source file:com.ayogo.cordova.notification.ScheduledNotificationManager.java
public void showNotification(ScheduledNotification scheduledNotification) { LOG.v(NotificationPlugin.TAG, "showNotification: " + scheduledNotification.toString()); NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); // Build the notification options builder.setDefaults(Notification.DEFAULT_ALL).setTicker(scheduledNotification.body) .setPriority(Notification.PRIORITY_HIGH).setAutoCancel(true); // TODO: add sound support // if (scheduledNotification.sound != null) { // builder.setSound(sound); // }/*from ww w .j a v a 2 s.c om*/ if (scheduledNotification.body != null) { builder.setContentTitle(scheduledNotification.title); builder.setContentText(scheduledNotification.body); builder.setStyle(new NotificationCompat.BigTextStyle().bigText(scheduledNotification.body)); } else { //Default the title to the app name try { PackageManager pm = context.getPackageManager(); ApplicationInfo applicationInfo = pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); String appName = applicationInfo.loadLabel(pm).toString(); builder.setContentTitle(appName); builder.setContentText(scheduledNotification.title); builder.setStyle(new NotificationCompat.BigTextStyle().bigText(scheduledNotification.title)); } catch (NameNotFoundException e) { LOG.v(NotificationPlugin.TAG, "Failed to set title for notification!"); return; } } if (scheduledNotification.badge != null) { LOG.v(NotificationPlugin.TAG, "showNotification: has a badge!"); builder.setSmallIcon(getResIdForDrawable(scheduledNotification.badge)); } else { LOG.v(NotificationPlugin.TAG, "showNotification: has no badge, use app icon!"); try { PackageManager pm = context.getPackageManager(); ApplicationInfo applicationInfo = pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Resources resources = pm.getResourcesForApplication(applicationInfo); builder.setSmallIcon(applicationInfo.icon); } catch (NameNotFoundException e) { LOG.v(NotificationPlugin.TAG, "Failed to set badge for notification!"); return; } } if (scheduledNotification.icon != null) { LOG.v(NotificationPlugin.TAG, "showNotification: has an icon!"); builder.setLargeIcon(getIconFromUri(scheduledNotification.icon)); } else { LOG.v(NotificationPlugin.TAG, "showNotification: has no icon, use app icon!"); try { PackageManager pm = context.getPackageManager(); ApplicationInfo applicationInfo = pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Resources resources = pm.getResourcesForApplication(applicationInfo); Bitmap appIconBitmap = BitmapFactory.decodeResource(resources, applicationInfo.icon); builder.setLargeIcon(appIconBitmap); } catch (NameNotFoundException e) { LOG.v(NotificationPlugin.TAG, "Failed to set icon for notification!"); return; } } Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); launchIntent.setAction("notification"); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(contentIntent); Notification notification = builder.build(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); LOG.v(NotificationPlugin.TAG, "notify!"); notificationManager.notify(scheduledNotification.tag.hashCode(), notification); }