I'm pretty new to Android development. Our teachers are telling us we should develop our app (which is a personal task) should make use of fragments. Now in API28 fragments are deprecated. Why is that exactly? What should you use now? I find a lot of different opinions on different things in Android development and as a newby it's hard to find what the good practices are.
Asked
Active
Viewed 1.1k times
2 Answers
9
It's only native fragments that are being deprecated. Use the compatibility library fragments and all will be well. See this thread for more info about the difference between native and compatibility fragments. From the docs for android.app.fragment
:
This class was deprecated in API level 28.
Use the Support Library Fragment for consistent behavior across all devices and access to Lifecycle.

Ted Hopp
- 232,168
- 48
- 399
- 521
5
Meanwhile there's also androidx.fragment.app.Fragment
,
which will supersede the android.support.v4.app.Fragment
.

Martin Zeitler
- 1
- 19
- 155
- 216