Home > Software design >  Which namespace to use for AlertDialog?
Which namespace to use for AlertDialog?

Time:08-25

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?

CodePudding user response:

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

  • Related