Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Weather App Concurrency and Error Handling Handling Errors

Michael Switzer
Michael Switzer
7,488 Points

The 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
STAFF
Ben Deitch
Treehouse Teacher

Hi 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!

Ben Deitch
Ben Deitch
Treehouse Teacher

Hey 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)

Derrick Showers
Derrick Showers
2,691 Points

Looks like if you're using the latest libraries, you actually want

import androidx.fragment.app.DialogFragment;

(see this SO post for details)