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:androidx.media.SessionToken2.java
private static String getSessionIdFromService(PackageManager manager, String serviceInterface, ComponentName serviceComponent) { Intent serviceIntent = new Intent(serviceInterface); // Use queryIntentServices to find services with MediaLibraryService2.SERVICE_INTERFACE. // We cannot use resolveService with intent specified class name, because resolveService // ignores actions if Intent.setClassName() is specified. serviceIntent.setPackage(serviceComponent.getPackageName()); List<ResolveInfo> list = manager.queryIntentServices(serviceIntent, PackageManager.GET_META_DATA); if (list != null) { for (int i = 0; i < list.size(); i++) { ResolveInfo resolveInfo = list.get(i); if (resolveInfo == null || resolveInfo.serviceInfo == null) { continue; }//from w w w . j a v a 2s. c o m if (TextUtils.equals(resolveInfo.serviceInfo.name, serviceComponent.getClassName())) { return getSessionId(resolveInfo); } } } return null; }
From source file:eu.trentorise.smartcampus.trentinofamiglia.fragments.poi.PoisListingFragment.java
private void setFollowByIntent() { try {//from www .j a va 2 s . c om ApplicationInfo ai = getActivity().getPackageManager() .getApplicationInfo(getActivity().getPackageName(), PackageManager.GET_META_DATA); Bundle aBundle = ai.metaData; mFollowByIntent = aBundle.getBoolean("follow-by-intent"); } catch (NameNotFoundException e) { mFollowByIntent = false; Log.e(PoisListingFragment.class.getName(), "you should set the follow-by-intent metadata in app manifest"); } }
From source file:jp.gr.java_conf.ya.shiobeforandroid3.UpdateTweetDrive.java
@Override protected final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build()); }//w w w. ja va 2 s . c o m simpleauth(); crpKey = getString(R.string.app_name); final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); crpKey += telephonyManager.getDeviceId(); crpKey += telephonyManager.getSimSerialNumber(); try { final PackageInfo packageInfo = getPackageManager() .getPackageInfo("jp.gr.java_conf.ya.shiobeforandroid3", PackageManager.GET_META_DATA); crpKey += Long.toString(packageInfo.firstInstallTime); } catch (NameNotFoundException e) { WriteLog.write(this, e); } adapter = new ListAdapter(this, crpKey, null, null); setContentView(R.layout.tweet_drive); tableLayout1 = (TableLayout) this.findViewById(R.id.tableLayout1); editText2 = (EditText) this.findViewById(R.id.editText2); editText4 = (EditText) this.findViewById(R.id.editText4); editText5 = (EditText) this.findViewById(R.id.editText5); editText2.setFocusable(true); editText2.setFocusableInTouchMode(true); editText2.requestFocusFromTouch(); pref_app = PreferenceManager.getDefaultSharedPreferences(this); final String pref_tl_fontfilename = pref_app.getString("pref_tl_fontfilename", ""); if (pref_tl_fontfilename.equals("") == false) { try { WriteLog.write(this, "pref_tl_fontfilename: " + pref_tl_fontfilename); fontUtil.loadFont(pref_tl_fontfilename, this); fontUtil.setFont(editText2, this); fontUtil.setFont(editText4, this); fontUtil.setFont(editText5, this); } catch (final Exception e) { WriteLog.write(this, e); } } final float pref_tl_fontsize_updatetweet = ListAdapter.getPrefFloat(this, "pref_tl_fontsize_updatetweet", "14"); editText2.setTextSize(pref_tl_fontsize_updatetweet); editText4.setTextSize(pref_tl_fontsize_updatetweet); editText5.setTextSize(pref_tl_fontsize_updatetweet); final String pref_tl_bgcolor_updatetweet = pref_app.getString("pref_tl_bgcolor_updatetweet", "#000000"); pref_tl_fontcolor_text_updatetweet = pref_app.getString("pref_tl_fontcolor_text_updatetweet", "#ffffff"); pref_tl_fontcolor_text_updatetweet_over = pref_app.getString("pref_tl_fontcolor_text_updatetweet_over", "#ff0000"); if (pref_tl_bgcolor_updatetweet.equals("") == false) { try { tableLayout1.setBackgroundColor(Color.parseColor(pref_tl_bgcolor_updatetweet)); } catch (final IllegalArgumentException e) { } } setTextColorOnTextChanged(); if (pref_tl_fontcolor_text_updatetweet.equals("") == false) { try { editText4.setTextColor(Color.parseColor(pref_tl_fontcolor_text_updatetweet)); editText5.setTextColor(Color.parseColor(pref_tl_fontcolor_text_updatetweet)); } catch (final IllegalArgumentException e) { } } editText2.addTextChangedListener(new TextWatcher() { @Override public final void afterTextChanged(final Editable s) { setTextColorOnTextChanged(); } @Override public final void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { } @Override public final void onTextChanged(final CharSequence s, final int start, final int before, final int count) { setTextColorOnTextChanged(); } }); editText2.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public final void onFocusChange(final View arg0, final boolean arg1) { setTextColorOnTextChanged(); } }); editText2.setOnLongClickListener(new View.OnLongClickListener() { @Override public final boolean onLongClick(final View v) { tweet(); return true; } }); map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); final String pref_map_site = pref_app.getString("pref_map_site", "0"); if (pref_map_site.equals("0")) { try { MapsInitializer.initialize(this); } catch (final Exception e) { toast("You must update Google Google Play Service."); } } else { try { map.setMapType(GoogleMap.MAP_TYPE_NONE); final TileProvider tileProvider = new UrlTileProvider(256, 256) { @Override public final synchronized URL getTileUrl(final int x, final int y, final int zoom) { // The moon tile coordinate system is reversed. This is not normal. // int reversedY = (1 << zoom) - y - 1; // String s = String.format(Locale.US, MOON_MAP_URL_FORMAT, zoom, x, reversedY); final String s = String.format(Locale.US, ((pref_map_site.equals("0")) ? ListAdapter.OSM_MAP_URL_FORMAT : ListAdapter.GSI_MAP_URL_FORMAT), zoom, x, y); URL url = null; try { url = new URL(s); } catch (final MalformedURLException e) { throw new AssertionError(e); } return url; } }; map.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider)); } catch (final Exception e) { try { MapsInitializer.initialize(this); } catch (final Exception e1) { toast("You must update Google Maps."); } } } moveTo(35.66279, 139.759848, 0.0f, 0.0f); }
From source file:com.aware.ui.Plugins_Manager.java
private void drawUI() { //Clear previous states store_grid.removeAllViews();/*from ww w . j av a2s. c o m*/ //Build UI Cursor installed_plugins = getContentResolver().query(Aware_Plugins.CONTENT_URI, null, null, null, Aware_Plugins.PLUGIN_NAME + " ASC"); if (installed_plugins != null && installed_plugins.moveToFirst()) { do { final String package_name = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_PACKAGE_NAME)); final String name = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME)); final String description = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_DESCRIPTION)); final String developer = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_AUTHOR)); final String version = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_VERSION)); final int status = installed_plugins .getInt(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_STATUS)); final View pkg_view = inflater.inflate(R.layout.plugins_store_pkg_list_item, null, false); pkg_view.setTag(package_name); //each view has the package name as a tag for easier references try { ImageView pkg_icon = (ImageView) pkg_view.findViewById(R.id.pkg_icon); if (status != PLUGIN_NOT_INSTALLED) { ApplicationInfo appInfo = getPackageManager().getApplicationInfo(package_name, PackageManager.GET_META_DATA); pkg_icon.setImageDrawable(appInfo.loadIcon(getPackageManager())); } else { byte[] img = installed_plugins .getBlob(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_ICON)); if (img != null) pkg_icon.setImageBitmap(BitmapFactory.decodeByteArray(img, 0, img.length)); } TextView pkg_title = (TextView) pkg_view.findViewById(R.id.pkg_title); pkg_title.setText(installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME))); ImageView pkg_state = (ImageView) pkg_view.findViewById(R.id.pkg_state); switch (status) { case PLUGIN_DISABLED: pkg_state.setVisibility(View.INVISIBLE); pkg_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = getPluginInfoDialog(name, version, description, developer); if (isClassAvailable(package_name, "Settings")) { builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent open_settings = new Intent(); open_settings.setClassName(package_name, package_name + ".Settings"); startActivity(open_settings); } }); } builder.setPositiveButton("Activate", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.startPlugin(getApplicationContext(), package_name); drawUI(); } }); builder.create().show(); } }); break; case PLUGIN_ACTIVE: pkg_state.setImageResource(R.drawable.ic_pkg_active); pkg_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = getPluginInfoDialog(name, version, description, developer); if (isClassAvailable(package_name, "Settings")) { builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent open_settings = new Intent(); open_settings.setClassName(package_name, package_name + ".Settings"); startActivity(open_settings); } }); } builder.setPositiveButton("Deactivate", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.stopPlugin(getApplicationContext(), package_name); drawUI(); } }); builder.create().show(); } }); break; case PLUGIN_UPDATED: pkg_state.setImageResource(R.drawable.ic_pkg_updated); pkg_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = getPluginInfoDialog(name, version, description, developer); if (isClassAvailable(package_name, "Settings")) { builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent open_settings = new Intent(); open_settings.setClassName(package_name, package_name + ".Settings"); startActivity(open_settings); } }); } builder.setNeutralButton("Deactivate", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.stopPlugin(getApplicationContext(), package_name); drawUI(); } }); builder.setPositiveButton("Update", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.downloadPlugin(getApplicationContext(), package_name, true); } }); builder.create().show(); } }); break; case PLUGIN_NOT_INSTALLED: pkg_state.setImageResource(R.drawable.ic_pkg_download); pkg_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = getPluginInfoDialog(name, version, description, developer); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton("Install", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.downloadPlugin(getApplicationContext(), package_name, false); } }); builder.create().show(); } }); break; } store_grid.addView(pkg_view); } catch (NameNotFoundException e) { e.printStackTrace(); } } while (installed_plugins.moveToNext()); } if (installed_plugins != null && !installed_plugins.isClosed()) installed_plugins.close(); }
From source file:io.flutter.embedding.engine.android.FlutterActivity.java
/** * The initial route that a Flutter app will render upon loading and executing its Dart code. * <p>// ww w . ja v a2s. com * This preference can be controlled with 2 methods: * <ol> * <li>Pass a boolean as {@link #EXTRA_INITIAL_ROUTE} with the launching {@code Intent}, or</li> * <li>Set a {@code <meta-data>} called {@link #INITIAL_ROUTE_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 initial route. */ @Nullable protected String getInitialRoute() { if (getIntent().hasExtra(EXTRA_INITIAL_ROUTE)) { return getIntent().getStringExtra(EXTRA_INITIAL_ROUTE); } try { ActivityInfo activityInfo = getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA | PackageManager.GET_ACTIVITIES); Bundle metadata = activityInfo.metaData; return metadata != null ? metadata.getString(INITIAL_ROUTE_META_DATA_KEY) : null; } catch (PackageManager.NameNotFoundException e) { return null; } }
From source file:org.apache.cordova.AndroidWebView.java
/** * Initialize webview.//from w ww . j ava 2 s. c o m */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") private void setup() { this.setInitialScale(0); this.setVerticalScrollBarEnabled(false); if (shouldRequestFocusOnInit()) { this.requestFocusFromTouch(); } // Enable JavaScript WebSettings settings = this.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL); // Set the nav dump for HTC 2.x devices (disabling for ICS, deprecated entirely for Jellybean 4.2) try { Method gingerbread_getMethod = WebSettings.class.getMethod("setNavDump", new Class[] { boolean.class }); String manufacturer = android.os.Build.MANUFACTURER; Log.d(TAG, "CordovaWebView is running on device made by: " + manufacturer); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB && android.os.Build.MANUFACTURER.contains("HTC")) { gingerbread_getMethod.invoke(settings, true); } } catch (NoSuchMethodException e) { Log.d(TAG, "We are on a modern version of Android, we will deprecate HTC 2.3 devices in 2.8"); } catch (IllegalArgumentException e) { Log.d(TAG, "Doing the NavDump failed with bad arguments"); } catch (IllegalAccessException e) { Log.d(TAG, "This should never happen: IllegalAccessException means this isn't Android anymore"); } catch (InvocationTargetException e) { Log.d(TAG, "This should never happen: InvocationTargetException means this isn't Android anymore."); } //We don't save any form data in the application settings.setSaveFormData(false); settings.setSavePassword(false); // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist // while we do this if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) Level16Apis.enableUniversalAccess(settings); // Enable database // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16 String databasePath = this.cordova.getActivity().getApplicationContext() .getDir("database", Context.MODE_PRIVATE).getPath(); settings.setDatabaseEnabled(true); settings.setDatabasePath(databasePath); //Determine whether we're in debug or release mode, and turn on Debugging! try { final String packageName = this.cordova.getActivity().getPackageName(); final PackageManager pm = this.cordova.getActivity().getPackageManager(); ApplicationInfo appInfo; appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { setWebContentsDebuggingEnabled(true); } } catch (IllegalArgumentException e) { Log.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! "); e.printStackTrace(); } catch (NameNotFoundException e) { Log.d(TAG, "This should never happen: Your application's package can't be found."); e.printStackTrace(); } settings.setGeolocationDatabasePath(databasePath); // Enable DOM storage settings.setDomStorageEnabled(true); // Enable built-in geolocation settings.setGeolocationEnabled(true); // Enable AppCache // Fix for CB-2282 settings.setAppCacheMaxSize(5 * 1048576); String pathToCache = this.cordova.getActivity().getApplicationContext() .getDir("database", Context.MODE_PRIVATE).getPath(); settings.setAppCachePath(pathToCache); settings.setAppCacheEnabled(true); // Fix for CB-1405 // Google issue 4641 this.updateUserAgentString(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateUserAgentString(); } }; this.cordova.getActivity().registerReceiver(this.receiver, intentFilter); } // end CB-1405 pluginManager = new PluginManager(this, this.cordova); jsMessageQueue = new NativeToJsMessageQueue(this, cordova); exposedJsApi = new AndroidExposedJsApi(pluginManager, jsMessageQueue); resourceApi = new CordovaResourceApi(this.getContext(), pluginManager); exposeJsInterface(); }
From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java
private int getNotificationIconResourceId(final String drawableResourceName) { final PackageManager packageManager = pinpointContext.getApplicationContext().getPackageManager(); try {// w w w .j a va 2 s .c om final String packageName = pinpointContext.getApplicationContext().getPackageName(); final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA); final Resources resources = packageManager.getResourcesForApplication(applicationInfo); if (drawableResourceName != null) { final int resId = resources.getIdentifier(drawableResourceName, "drawable", packageName); if (resId != INVALID_RESOURCE) { return resId; } } return applicationInfo.icon; } catch (final PackageManager.NameNotFoundException ex) { log.error("Can't find icon for our application package.", ex); // 0 is an invalid resource id, so use it to indicate failure to // retrieve the resource. return INVALID_RESOURCE; } }
From source file:com.anysoftkeyboard.addons.AddOnsFactory.java
private boolean isPackageContainAnAddon(String packageNameSchemePart) throws NameNotFoundException { PackageInfo newPackage = mContext.getPackageManager().getPackageInfo(packageNameSchemePart, PackageManager.GET_RECEIVERS + PackageManager.GET_META_DATA); if (newPackage.receivers != null) { ActivityInfo[] receivers = newPackage.receivers; for (ActivityInfo aReceiver : receivers) { //issue 904 if (aReceiver == null || aReceiver.applicationInfo == null || !aReceiver.enabled || !aReceiver.applicationInfo.enabled) continue; final XmlPullParser xml = aReceiver.loadXmlMetaData(mContext.getPackageManager(), mReceiverMetaData);/*from w w w. j a v a2 s.co m*/ if (xml != null) { return true; } } } return false; }
From source file:de.quist.app.errorreporter.ExceptionReportService.java
public Uri getTargetUrl() throws NameNotFoundException { ApplicationInfo info = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); if (ai.metaData == null) throw new IllegalArgumentException( ExceptionReportService.class.getPackage().getName().concat("targetUrl is undefined")); String key = ExceptionReportService.class.getPackage().getName().concat(".targetUrl"); String urlString = null;//from www.j a v a2s . c o m if (info.metaData.containsKey(key)) { Object url = info.metaData.get(key); if (url instanceof String) { urlString = (String) url; } else if (url instanceof Integer) { int urlResId = info.metaData.getInt(key); urlString = getString(urlResId); } } if (urlString == null) { throw new IllegalArgumentException( ExceptionReportService.class.getPackage().getName().concat("targetUrl is undefined")); } return Uri.parse(urlString); }
From source file:cn.bingoogolapple.scaffolding.util.AppManager.java
/** * ???/* w w w. ja v a 2s .com*/ * * @return */ private static String getChannel() { try { ApplicationInfo appInfo = sApp.getPackageManager().getApplicationInfo(sApp.getPackageName(), PackageManager.GET_META_DATA); return appInfo.metaData.getString("UMENG_CHANNEL"); } catch (Exception e) { return ""; } }