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

setBackgroundDrawable() deprecated

It’s an interesting topic. The way you are doing it is correct, apparently. It is actually just a naming decision change. As this answer points out, setBackground() just calls setBackgroundDrawable(): public void setBackground(Drawable background) { //noinspection deprecation setBackgroundDrawable(background); } @Deprecated public void setBackgroundDrawable(Drawable background) { … } You can see this thread for more information … Read more

Glut deprecation in Mac OSX 10.9, IDE: QT Creator

You can still use it in 10.9. They’re sending you a pretty strong signal that they want you to stop, though… You can disable those warnings with the -Wno-deprecated-declarations compiler option. There’s also some difficulties including the right headers if you’re trying to use GL3 level features, because you need to include gl3.h for that, … Read more

Gradle warning: variant.getOutputFile() and variant.setOutputFile() are deprecated

Building on the answer from Larry Schiefer you can change the script to something like this: android { applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith(‘.apk’)) { def fileName = outputFile.name.replace(‘.apk’, “-${versionName}.apk”) output.outputFile = new File(outputFile.parent, fileName) } } } }

Django 1.9 deprecation warnings app_label

Similar error. In my case the error was: RemovedInDjango19Warning: Model class django.contrib.sites.models.Site doesn’t declare an explicit app_label and either isn’t in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9. class Site(models.Model): My solution was: Added ‘django.contrib.sites’ to INSTALLED_APPS

variantOutput.getPackageApplication() is obsolete

variantOutput.getPackageApplication() is being caused by a changed variant API. changing output.outputFile.parent to variant.getPackageApplicationProvider().get().outputs.files[1] is at least a temporary workaround. source: @Selvin. variant.getExternalNativeBuildTasks() is being caused by the io.fabric plugin. the next version of the io.fabric plugin will use variant.getExternalNativeBuildProviders(). source: 116408637; the confirmation for a promised fix (1.28.1). These are caused by com.google.gms.google-services: registerResGeneratingTask is … Read more

DeprecationWarning: firefox_profile has been deprecated, please pass in an Options object

Here is the documentation for this: https://www.selenium.dev/documentation/webdriver/capabilities/driver_specific_capabilities/#setting-a-custom-profile I tried this locally and it worked: EDITED: I’ve changed the code, so there are no deprecation warnings from selenium.webdriver import Firefox from selenium.webdriver.firefox.service import Service from selenium.webdriver.firefox.options import Options profile_path = r’C:\Users\Administrator\AppData\Roaming\Mozilla\Firefox\Profiles\y1uqp5mi.default’ options=Options() options.set_preference(‘profile’, profile_path) service = Service(r’C:\WebDriver\bin\geckodriver.exe’) driver = Firefox(service=service, options=options) driver.get(“https://selenium.dev”) driver.quit()

Is `shouldOverrideUrlLoading` really deprecated? What can I use instead?

Documenting in detail for future readers: The short answer is you need to override both the methods. The shouldOverrideUrlLoading(WebView view, String url) method is deprecated in API 24 and the shouldOverrideUrlLoading(WebView view, WebResourceRequest request) method is added in API 24. If you are targeting older versions of android, you need the former method, and if … Read more