01
02
03
04
05
06
07
08
09
10
| File videoFile2Play = new File("/sdcard/nice_movie.mpeg"); Intent i = new Intent(); i.setAction(android.content.Intent.ACTION_VIEW); i.setDataAndType(Uri.fromFile(videoFile2Play), "video/mpeg"); startActivity(i); File musicFile2Play = new File("/sdcard/some_file.mp3"); Intent i2 = new Intent(); i2.setAction(android.content.Intent.ACTION_VIEW); i2.setDataAndType(Uri.fromFile(musicFile2Play), "audio/mp3"); startActivity(i2); |
1
2
3
| File videoFile2Play2 = new File("/sdcard/nice_movie2.mp4"); i.setDataAndType(Uri.fromFile(videoFile2Play2), "video/*"); startActivity(i); |
| Extension | MIME Type | |
| Android Application | .apk | application/vnd.android.package-archive |
| Text | .txt | text/plain |
| .csv | text/csv | |
| .xml | text/xml | |
| Web related | .htm | text/html |
| .html | text/html | |
| .php | text/php | |
| Image | .png | image/png |
| .gif | image/gif | |
| .jpg | image/jpg | |
| .jpeg | image/jpeg | |
| .bmp | image/bmp | |
| Audio | .mp3 | audio/mp3 |
| .wav | audio/wav | |
| .ogg | audio/x-ogg | |
| .mid | audio/mid | |
| .midi | audio/midi | |
| .amr | audio/AMR | |
| Video | .mpeg | video/mpeg |
| .3gp | video/3gpp | |
| Package | .jar | application/java-archive |
| .zip | application/zip | |
| .rar | application/x-rar-compressed | |
| .gz | application/gzip |
For more info on MIME types and files handling based on their extension take a look at the MIMETypeMap documentation.
沒有留言:
張貼留言