{"action":"created","issue":{"url":"https://api.github.com/repos/android-cn/android-discuss/issues/398","repository_url":"https://api.github.com/repos/android-cn/android-discuss","labels_url":"https://api.github.com/repos/android-cn/android-discuss/issues/398/labels{/name}","comments_url":"https://api.github.com/repos/android-cn/android-discuss/issues/398/comments","events_url":"https://api.github.com/repos/android-cn/android-discuss/issues/398/events","html_url":"https://github.com/android-cn/android-discuss/issues/398","id":139796124,"number":398,"title":"【问答】怎么获取android手机里所有的视频文件","user":{"login":"orangecoder","id":2263785,"avatar_url":"https://avatars.githubusercontent.com/u/2263785?v=3","gravatar_id":"","url":"https://api.github.com/users/orangecoder","html_url":"https://github.com/orangecoder","followers_url":"https://api.github.com/users/orangecoder/followers","following_url":"https://api.github.com/users/orangecoder/following{/other_user}","gists_url":"https://api.github.com/users/orangecoder/gists{/gist_id}","starred_url":"https://api.github.com/users/orangecoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orangecoder/subscriptions","organizations_url":"https://api.github.com/users/orangecoder/orgs","repos_url":"https://api.github.com/users/orangecoder/repos","events_url":"https://api.github.com/users/orangecoder/events{/privacy}","received_events_url":"https://api.github.com/users/orangecoder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-10T06:08:10Z","updated_at":"2016-03-23T09:42:01Z","closed_at":null,"body":"### 说明\r\n主要想实现的效果是可以查看手机里所有的视频文件，用户可以通过下拉刷新更新视频列表\r\n\r\n### 目前发现有以下两种方法\r\n\r\n1 [用 File.listfile() 方法设置 FileFilter 监听器过滤后缀名](http://blog.csdn.net/huichengongzi/article/details/9094489)\r\n\r\n缺点：用户每次下拉刷新扫描整个sdcard和生成视频缩略图的时间较长，没用后缀名的视频文件扫描不到\r\n\r\n2 从 MediaStore.Video.Media.EXTERNAL_CONTENT_URI 获取\r\n\r\n优点：快，不用自己生成视频缩略图\r\n缺点：有些新视频信息没有写入MediaStore导致扫描不到\r\n\r\n目前采用的是第二种解决方法，不知大家有没有更好的思路可以分享一下，谢谢！"},"comment":{"url":"https://api.github.com/repos/android-cn/android-discuss/issues/comments/200270850","html_url":"https://github.com/android-cn/android-discuss/issues/398#issuecomment-200270850","issue_url":"https://api.github.com/repos/android-cn/android-discuss/issues/398","id":200270850,"user":{"login":"dxjia","id":11327714,"avatar_url":"https://avatars.githubusercontent.com/u/11327714?v=3","gravatar_id":"","url":"https://api.github.com/users/dxjia","html_url":"https://github.com/dxjia","followers_url":"https://api.github.com/users/dxjia/followers","following_url":"https://api.github.com/users/dxjia/following{/other_user}","gists_url":"https://api.github.com/users/dxjia/gists{/gist_id}","starred_url":"https://api.github.com/users/dxjia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dxjia/subscriptions","organizations_url":"https://api.github.com/users/dxjia/orgs","repos_url":"https://api.github.com/users/dxjia/repos","events_url":"https://api.github.com/users/dxjia/events{/privacy}","received_events_url":"https://api.github.com/users/dxjia/received_events","type":"User","site_admin":false},"created_at":"2016-03-23T09:42:01Z","updated_at":"2016-03-23T09:42:01Z","body":"@hewking 发广播给media，带上文件地址，它会自动更新数据库；\r\n```\r\n    private void updateMedia(File file) {\r\n        Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);\r\n        Uri uri = Uri.fromFile(file);\r\n        intent.setData(uri);\r\n        mContext.sendBroadcast(intent);\r\n    }\r\n```"}}