Where is the SampleZipfileProvider class?

戏子无情 提交于 2019-12-28 05:52:11

问题


At the bottom of the section in Google's dev guide on expansion files (http://developer.android.com/guide/market/expansion-files.html#ZipLib) there is the following text.

APEZProvider - Most applications don't need to use this class. This class defines a ContentProvider that marshals the data from the ZIP files through a content provider Uri in order to provide file access for certain Android APIs that expect Uri access to media files. The sample application available in the Apk Expansion package demonstrates a scenario in which this class is useful to specify a video with VideoView.setVideoURI(). See the sample app's class SampleZipfileProvider for an example of how to extend this class to use in your application.

The sample application in question doesn't contain this class. But it does contain a reference to a .SampleVideoPlayerActivity file in the AndroidManifest.xml, which is not present in the project either.

Has anyone tried to implement a concrete class based on the APEZProvider and used it with VideoView.setVideoURI()?

I have implemented the class:

public class ZipFileContentProvider extends APEZProvider {

    @Override
    public String getAuthority() {
        return "com.myCompany.myAppName.provider.ZipFileContentProvider";
    }
}

But I don't know how to use it with the VideoView.setVideoURI() call. Can anyone help?


回答1:


It turned out that my ZipFileContentProvider was sufficient. For those coming across this problem. Here is what I did to use the content provider for the VideoView.setVideoURI() method.

Add provider to Manifest.

<provider android:authorities="com.myCompany.myAppName.provider.ZipFileContentProvider" android:name=".ZipFileContentProvider"></provider>

In video player class:

final String AUTHORITY = "com.myCompany.myAppName.provider.ZipFileContentProvider";
final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
video = (VideoView) findViewById(R.id.video);
video.setVideoURI(Uri.parse(CONTENT_URI + "/" + videoFileName + ".mp4"));


来源:https://stackoverflow.com/questions/9623350/where-is-the-samplezipfileprovider-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!