warning: [deprecation] scaledDensity in DisplayMetrics has been deprecated

Reference: https://developer.android.com/reference/android/util/DisplayMetrics#scaledDensity

This method is deprecated from API level 34, so if you want to get the dimensions of the application window then you can safely manage this situation with:

DisplayMetrics dm = getResources().getDisplayMetrics();
float scaledDensity;
if (Build.VERSION.SDK_INT >= 34)
    scaledDensity = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, dm);
else
    scaledDensity = dm.scaledDensity;

warning: [deprecation] getMetrics(DisplayMetrics) in Display has been deprecated

Reference: https://developer.android.com/reference/android/view/Display#getMetrics(android.util.DisplayMetrics)

This method is deprecated from API level 30, so if you want to get the dimensions of the application window then you can safely manage this situation with:

if (Build.VERSION.SDK_INT >= 30) {
    WindowManager windowManager = (WindowManager)
        getSystemService(WINDOW_SERVICE);
    final WindowMetrics metrics = windowManager.getCurrentWindowMetrics();
    // Gets all excluding insets
    final WindowInsets windowInsets = metrics.getWindowInsets();
    Insets insets =
     windowInsets.getInsetsIgnoringVisibility(WindowInsets.Type.navigationBars()| WindowInsets.Type.displayCutout());

    int insetsWidth = insets.right + insets.left;
    int insetsHeight = insets.top + insets.bottom;

    // Legacy size that Display#getSize reports
    final Rect bounds = metrics.getBounds();
    final Size legacySize = new Size(bounds.width() - insetsWidth,bounds.height() - insetsHeight);
}

warning: [deprecation] getDefaultDisplay() in WindowManager has been deprecated

Reference: https://developer.android.com/reference/android/view/WindowManager#getDefaultDisplay()

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

Display display;
if (Build.VERSION.SDK_INT >= 30)
    display = this.getDisplay();
else {
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    display = wm.getDefaultDisplay();
}

Be careful that this is referred to an activity that is displayed on that display or read major documentation here: https://developer.android.com/reference/android/content/Context#getDisplay()

compileSdkVersion is deprecated

Reference:

https://developer.android.com/reference/tools/gradle-api/8.2/com/android/build/api/dsl/CommonExtension#compileSdkVersion(kotlin.Int)

and buildToolsVersion too:

https://developer.android.com/reference/tools/gradle-api/8.2/com/android/build/api/dsl/CommonExtension#buildToolsVersion()

This method is deprecated, so you can safely manage this situation in your build.gradle file at module leve (not the App) with:

android {
    compileSdk 34
    buildToolsVersion = "34.0.0"
    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 21
        targetSdkVersion 34
        versionCode 10000
        versionName "1.00.00"
    }
[...]
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

warning: [deprecation] readParcelable(ClassLoader) in Parcel has been deprecated

Reference:

https://developer.android.com/reference/android/os/Parcel#readParcelable(java.lang.ClassLoader)

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

Parcel in;
LatLng latLng;
if (Build.VERSION.SDK_INT >= 33)  // new version
    latLng = in.readParcelable(LatLng.class.getClassLoader(), LatLng.class);
else  // old version
    latLng = in.readParcelable(LatLng.class.getClassLoader());

warning: [deprecation] getParcelableExtra(String) in Intent has been deprecated

Reference:

https://developer.android.com/reference/android/content/Intent#getParcelableExtra(java.lang.String)

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

Uri uri;
if (Build.VERSION.SDK_INT >= 33)
    uri = intentResult
        .getParcelableExtra(
            RingtoneManager.EXTRA_RINGTONE_PICKED_URI, 
            Uri.class
        );
else
    uri = intentResult
        .getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);

warning: [deprecation] vibrate(long[],int) in Vibrator has been deprecated

Reference:

https://developer.android.com/reference/android/os/Vibrator#vibrate(long), and following methods

These methods have been deprecated too:

public void vibrate (long milliseconds)
public void vibrate (long[] pattern, int repeat)
public void vibrate (VibrationEffect vibe, AudioAttributes attributes)
public void vibrate (long milliseconds, AudioAttributes attributes)
public void vibrate (long[] pattern, int repeat, AudioAttributes attributes)

These methods have been deprecated from API level 26 and have been superseded by these two new methods:

public void vibrate (VibrationEffect vibe, VibrationAttributes attributes)
public void vibrate (VibrationEffect vibe)

so you can safely manage this situation with:

if (Build.VERSION.SDK_INT >= 26) // new version
    vibrator.vibrate(createOneShot(1000, VibrationEffect.DEFAULT_AMPLITUDE));
else  // old version
    vibrator.vibrate(patternTiming, 0);

Related: https://www.cascablog.it/2024/04/01/warning-deprecation-vibrator_service-in-context-has-been-deprecated/

warning: [deprecation] VIBRATOR_SERVICE in Context has been deprecated

Reference:

https://developer.android.com/reference/android/content/Context#VIBRATOR_SERVICE

This constant has been deprecated from API level 31, so you can safely manage this situation with:

Vibrator vibrator;

if (Build.VERSION.SDK_INT >= 31) {
    VibratorManager vibratorM = (VibratorManager) getApplicationContext()
        .getSystemService(Context.VIBRATOR_MANAGER_SERVICE);
    vibrator = vibratorM.getDefaultVibrator();
} else
    vibrator = (Vibrator) getApplicationContext
        .getSystemService(Context.VIBRATOR_SERVICE);

// then continue for example with...
vibrator.cancel();

Related: https://www.cascablog.it/2024/04/01/warning-deprecation-vibratelongint-in-vibrator-has-been-deprecated/

warning: [deprecation] FLAG_TURN_SCREEN_ON in LayoutParams has been deprecated

Reference:

https://developer.android.com/reference/android/view/WindowManager.LayoutParams#FLAG_TURN_SCREEN_ON

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

Adding the FLAG_TURN_SCREEN_ON flag to the flags of the current window typically happens in the onCreate event and BEFORE the method SetContent() of an activity; after the deprecation, instead, you have to call the setTurnScreenOn(boolean) method:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT < 27) // the old version
        getWindow()
            .addFlags(
                WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            );
    else  // the new version
         setTurnScreenOn(true);

    setContentView(R.layout.main_activity);
}

warning: [deprecation] FLAG_SHOW_WHEN_LOCKED in LayoutParams has been deprecated

Reference:

https://developer.android.com/reference/android/view/WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED

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

Adding the FLAG_SHOW_WHEN_LOCKED flag to the flags of the current window typically happens in the onCreate event and BEFORE the method SetContent() of an activity; after the deprecation, instead, you have to call the setShowWhenLocked(boolean) method:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT < 27) // the old version
        getWindow()
            .addFlags(
                WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            );
    else  // the new version
         setShowWhenLocked(true);

    setContentView(R.layout.main_activity);
}