Which namespace to use for AlertDialog?

Issue

I am updating some code in my Xamarin.Android project to AndroidX. I see AlertDialog in 3 different namespaces:

var alert1 = new Android.Support.V7.App.AlertDialog.Builder(activity);
var alert2 = new Android.App.AlertDialog.Builder(activity);
var alert3 = new AndroidX.AppCompat.App.AlertDialog.Builder(activity);

What is the difference? And which one should I use?

Solution

Android.App is in the native version of the Android SDK.
Android.Support is in the android support library
AndroidX comes with androidX library

Androidx and Android.Support libraries provides additional features compared to the standard one

Android.Support is being replaced to Androidx libraries. i.e there wont be any new updates to Android.Support libraries
https://developer.android.com/topic/libraries/support-library/packages

The Android Support namespace was last released in version 28.0 of the Android Support Library, and it is no longer being developed. Therefore, AndroidX will be the platform for all new features and bug fixes.

Since you are moving your app to AndroidX, it is good to go with AndroidX

Answered By – Bhargavi

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published