warning: [deprecation] getColor(int) in Resources has been deprecated

Reference:

https://developer.android.com/reference/android/content/res/Resources#getColor(int)https://developer.android.com/reference/android/content/res/Resources#getColor(int)

This method is deprecated from API level 23, so you can safely manage this situation with:

int MyColor=0;
if (Build.VERSION.SDK_INT >= 23) // the new version of the API
     myColor = getResources()
        .getColor(
            R.color.primaryColor, 
            getActivity.getTheme()
        )
     );
else  // the old version of the API
    myColor = getResources()
        .getColor(R.color.primaryColor));

warning: [deprecation] getInstallerPackageName(String) in PackageManager has been deprecated

Reference: https://developer.android.com/reference/android/content/pm/PackageManager#getInstallerPackageName(java.lang.String)

This Method is deprecated from API level 30, so you can safely manage this situation with:

if (Build.VERSION.SDK_INT >= 30) {

    InstallSourceInfo isi = getContext()
        .getPackageManager()
        .getInstallSourceInfo(getContext()
        .getPackageName());

    // now, with an InstallSourceInfo object, you have access to three useful methods

    String initiating = isi.getInitiatingPackageName();
    String installing = isi.getInstallingPackageName();
    String originating = isi.getOriginatingPackageName();

} else { // continue to use the old version API

    String installerPackageName = getContext()
        .getPackageManager()
        .getInstallerPackageName(
            getContext().getPackageName()
        );
}

getInitiatingPackageName returns the name of the package that requested the installation, or null if not available. This is normally the same as the old getInstallerPackageName.

Adaptive banner: deprecation in computation

Adaptive banner: the actual implementation

In Google developers article where it explain how to create an adaptive banner, the showing code appears to be obsolete and some deprecation appears:

private AdSize getAdSize() {
    // Step 2 - Determine the screen width (less decorations) to use for the ad width.
    Display display = getWindowManager().getDefaultDisplay();
    DisplayMetrics outMetrics = new DisplayMetrics();
    display.getMetrics(outMetrics);

    float widthPixels = outMetrics.widthPixels;
    float density = outMetrics.density;

    int adWidth = (int) (widthPixels / density);

    // Step 3 - Get adaptive ad size and return for setting on the ad view.
    return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth);
  }
Continue reading “Adaptive banner: deprecation in computation”