Getting screen width on API Level 30 (Android 11): getDefaultDisplay() and getMetrics() are now deprecated. What should we use instead?

For calculating screen width minus any system bars, this should work: public static int getScreenWidth(@NonNull Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { WindowMetrics windowMetrics = activity.getWindowManager().getCurrentWindowMetrics(); Insets insets = windowMetrics.getWindowInsets() .getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()); return windowMetrics.getBounds().width() – insets.left – insets.right; } else { DisplayMetrics displayMetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.widthPixels; } } Note that this isn’t … Read more

Migration to PHP 8.1 – how to fix Deprecated Passing null to parameter error – rename build in functions

Firstly, two things to bear in mind: PHP 8.1 deprecates these calls, it does not make them errors. The purpose of deprecation is to give authors advance notice to fix their code, so you and the authors of libraries you use have until PHP 9.0 comes out to fix things. So, don’t panic that not … Read more

FacebookSdk.sdkInitialize (Context) is deprecated

From the documentation about upgrading SDK: The Facebook SDK is now auto initialized on Application start. If you are using the Facebook SDK in the main process and don’t need a callback on SDK initialization completion you can now remove calls to FacebookSDK.sdkInitialize. If you do need a callback, you should manually invoke the callback … Read more

How can I mark a C++ class method as deprecated?

In C++14, you can mark a function as deprecated using the [[deprecated]] attribute (see section 7.6.5 [dcl.attr.deprecated]). The attribute-token deprecated can be used to mark names and entities whose use is still allowed, but is discouraged for some reason. For example, the following function foo is deprecated: [[deprecated]] void foo(int); It is possible to provide … Read more

Why is the Date constructor deprecated, and what do I use instead?

The java.util.Date class isn’t actually deprecated, just that constructor, along with a couple other constructors/methods are deprecated. It was deprecated because that sort of usage doesn’t work well with internationalization. The Calendar class should be used instead: Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 1988); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); Date dateRepresentation = cal.getTime(); Take a look at … Read more

Replacement for “purpose” property of CLLocationManager

The replacement for the purpose property in iOS 6 is a new Info.plist key named NSLocationUsageDescription (aka “Privacy – Location Usage Description”). The key is documented in the Information Property List Key Reference but unfortunately it’s not mentioned with the deprecation note of the purpose property. However, the CLLocationManager.h does have this comment: * Deprecated. … Read more

What is the clearest way to deprecate a package in Java?

I had to do this recently and used the package-info.java file to deprecate the package. http://www.intertech.com/Blog/whats-package-info-java-for/ Add a package-info.java file to your package with only the package declaration: /** * @deprecated As of release 2.0, replaced by {@link com.acme.new.package} */ @Deprecated package com.acme.old.package; In Eclipse, all places where the user imports a class from this … Read more

JasperReports 5.6: JRXlsExporter.setParameter is deprecated

JRExporter became deprecated in 5.6. They introduced new interface Exporter and retrofitted all exporters to have ExporterInput, ReportExportConfiguration, ExporterConfiguration,ExporterOutput. See below link http://jasperreports.sourceforge.net/api/net/sf/jasperreports/export/Exporter.html This means that instead of setParameter, you need to create configuration using above mentioned classes or their child classes PDF export example. Excel export should follow same methodology JRPdfExporter exporter = new … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)