Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Switzer
7,490 PointsThe class "android.app.DialogFragment" is deprecated in API 28. What should we use instead?
When creating the class "AlertDialogFragment" from the video, I was adding the superclass and Android Studio alerted me that the class "android.app.DialogFragment" was deprecated in API 28. Obviously it still works, but I was wondering what should be used instead?
This is the documentation, I'm just not sure what I'm looking at: https://developer.android.com/reference/android/app/DialogFragment
2 Answers
Ben Deitch
Treehouse TeacherHi Michael! It just wants you to use the version of that class from the support library. Try changing 'android.app.DialogFragment' to 'android.support.v4.app.DialogFragment'.
Let me know if that doesn't work!
Derrick Showers
2,691 PointsLooks like if you're using the latest libraries, you actually want
import androidx.fragment.app.DialogFragment;
(see this SO post for details)
Ben Deitch
Treehouse TeacherBen Deitch
Treehouse TeacherHey Kamran! You'll need to override the 'onCreateDialog' function. Here's a link to the docs if it helps: https://developer.android.com/reference/android/support/v4/app/DialogFragment.html#onCreateDialog(android.os.Bundle)