How to add cookies (Header) as an Android view to support older versions of android, at least until jellybean

I have an activity that has a VideoView for playing videos.

I just set the uri to VideoView as shown below.

  videoView.setVideoURI(videoUri); 

After some searching, I found an alternative below that can take on header values

 videoView.setVideoURI(videoUri,headers); 

Here the headers are the HashMap in which cookies are added.

But As mentioned in this url http://developer.android.com/reference/android/widget/VideoView.html#setVideoURI(android.net.Uri , java.util.Map)

This new method was added in api 21 as it does not support in older versions. Is there a way to support this feature in older versions. Please help.

The need for this is basically I need to send session cookies to VideoView , which need to be played on video.

Please note that this is my first question on stackoverflow. Please let me know if you need information in order to get more information on this issue.

+4
source share
1 answer

I'm not sure, but I would suggest something like this:

  CookieSyncManager.createInstance(videoView.getContext()); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); cookieManager.setCookie(videoDomainURL, cookie_value); CookieSyncManager.getInstance().sync(); videoView.setVideoURI(videoUri); 
-one
source

All Articles