FragmentActivity.getSupportMediaController() is deprecated
Asked Answered
W

2

6

For getting a MediaControllerCompat instance I'm using getSupportMediaController() in FragmentActivity. But this method is deprecated. Which method do I have to use instead of this method?

Wish answered 8/1, 2017 at 11:44 Comment(0)
W
5

Just check the Android official docs .. https://developer.android.com/reference/android/support/v4/app/FragmentActivity.html

It tells you everything.

According to Android Developer documentation :

This method is deprecated.Use getMediaController() instead. This API will be removed in a future release.

So you have to use getMediaController() instead of getSupportMediaController()

To support devices older than SDK level 21 use MediaControllerCompat.getMediaController(activity)

Wish answered 8/1, 2017 at 11:44 Comment(1)
This does not provide MediaControllerCompat (the compatibility version of MediaController) to offer support to devices older than SDK level 21. Use MediaControllerCompat.getMediaController(activity) instead.Tiling
B
9

If you still want a MediaControllerCompat instance there is a way to get it since getMediaController() doesn't return the compatibility version of this class:

MediaControllerCompat.getMediaController(activity)

I found this info in the Revision 26.0.0 Beta 1 of Support Library changelog:

FragmentActivity.setSupportMediaController() and FragmentActivity.getSupportMediaController() have been removed. Please use the new static MediaControllerCompat.setMediaController() and MediaControllerCompat.getMediaController() methods.

Blancmange answered 27/5, 2017 at 20:52 Comment(0)
W
5

Just check the Android official docs .. https://developer.android.com/reference/android/support/v4/app/FragmentActivity.html

It tells you everything.

According to Android Developer documentation :

This method is deprecated.Use getMediaController() instead. This API will be removed in a future release.

So you have to use getMediaController() instead of getSupportMediaController()

To support devices older than SDK level 21 use MediaControllerCompat.getMediaController(activity)

Wish answered 8/1, 2017 at 11:44 Comment(1)
This does not provide MediaControllerCompat (the compatibility version of MediaController) to offer support to devices older than SDK level 21. Use MediaControllerCompat.getMediaController(activity) instead.Tiling

© 2022 - 2024 — McMap. All rights reserved.