B.Cakir
B.Cakir

Reputation: 607

DialogFragment Class Deprecated in Android P

The Android Documentation gives the following warning.

This class was deprecated in API level P. Use the Support Library DialogFragment for consistent behavior across all devices and access to Lifecycle.

Does this simply mean that the only change for me as a developer is to import android.support.v4.app.DialogFragment instead of the old android.app.DialogFragment?

Upvotes: 33

Views: 24644

Answers (2)

Swapnil Patil
Swapnil Patil

Reputation: 200

Change your import statement from android.app.DialogFragment to androidx.fragment.app.DialogFragment

Upvotes: 1

eManna
eManna

Reputation: 2482

Google is encouraging all developers to shift from the ordinary DialogFragment to the support version of the same class, you can still use the deprecated version of course but if Google recommends the support version, why wouldn't you?

Simply change your import statement from android.app.DialogFragment to android.support.v4.app.DialogFragment.

Also, consider changing all the imports if you are using the deprecated version of normal fragments.

UPDATE

If you are using the brand new AndroidX library instead of the old support library change it to androidx.fragment.app.DialogFragment but pay attention about how you are using the DialogFragment in your code because you have to migrate also to the new androidx.fragment.app.FragmentActivity.

Upvotes: 60

Related Questions