Android中簡(jiǎn)單調(diào)用圖片、視頻、音頻、錄音和拍照的方法
本文實(shí)例講述了Android中簡(jiǎn)單調(diào)用圖片、視頻、音頻、錄音和拍照的方法。分享給大家供大家參考,具體如下:
//選擇圖片 requestCode 返回的標(biāo)識(shí)
Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT); //"android.intent.action.GET_CONTENT"
innerIntent.setType(contentType); //查看類型 String IMAGE_UNSPECIFIED = "image/*";
Intent wrapperIntent = Intent.createChooser(innerIntent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
//視頻
Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT);
innerIntent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = Intent.createChooser(innerIntent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
//添加音頻
Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT);
innerIntent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*";
Intent wrapperIntent = Intent.createChooser(innerIntent, null);
((Activity) context).startActivityForResult(wrapperIntent, requestCode);
//錄音
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(ContentType.AUDIO_AMR); //String AUDIO_AMR = "audio/amr";
intent.setClassName("com.android.soundrecorder",
"com.android.soundrecorder.SoundRecorder");
((Activity) context).startActivityForResult(intent, requestCode);
//拍攝視頻
int durationLimit = getVideoCaptureDurationLimit(); //SystemProperties.getInt("ro.media.enc.lprof.duration", 60);
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationLimit);
startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO);
//拍照 REQUEST_CODE_TAKE_PICTURE 為返回的標(biāo)識(shí)
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //"android.media.action.IMAGE_CAPTURE";
intent.putExtra(MediaStore.EXTRA_OUTPUT, Mms.ScrapSpace.CONTENT_URI); // output,Uri.parse("content://mms/scrapSpace");
startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE);
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android開發(fā)入門與進(jìn)階教程》、《Android視圖View技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android操作SQLite數(shù)據(jù)庫技巧總結(jié)》、《Android操作json格式數(shù)據(jù)技巧總結(jié)》、《Android數(shù)據(jù)庫操作技巧總結(jié)》、《Android文件操作技巧匯總》、《Android編程開發(fā)之SD卡操作方法匯總》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
- Android編程錄音工具類RecorderUtil定義與用法示例
- Android編程實(shí)現(xiàn)錄音及保存播放功能的方法【附demo源碼下載】
- Android編程檢測(cè)手機(jī)錄音權(quán)限是否打開的方法
- Android實(shí)現(xiàn)錄音功能實(shí)現(xiàn)實(shí)例(MediaRecorder)
- android語音即時(shí)通訊之錄音、播放功能實(shí)現(xiàn)代碼
- Android6.0編程實(shí)現(xiàn)雙向通話自動(dòng)錄音功能的方法詳解
- Android使用AudioRecord實(shí)現(xiàn)暫停錄音功能實(shí)例代碼
- Android 錄音與播放功能的簡(jiǎn)單實(shí)例
- Android編程實(shí)現(xiàn)通話錄音功能的方法
- 利用libmp3lame實(shí)現(xiàn)在Android上錄音MP3文件示例
- Android錄音--AudioRecord、MediaRecorder的使用
- android 通過MediaRecorder實(shí)現(xiàn)簡(jiǎn)單的錄音示例
- Android使用MediaRecorder實(shí)現(xiàn)錄音及播放
- Android錄音播放管理工具
- Android實(shí)現(xiàn)拍照、錄像、錄音代碼范例
- Android實(shí)現(xiàn)自制和播放錄音程序
- Android編程開發(fā)錄音和播放錄音簡(jiǎn)單示例
- Android錄音mp3格式實(shí)例詳解
相關(guān)文章
Android編寫文件瀏覽器簡(jiǎn)單實(shí)現(xiàn)
這篇文章主要為大家詳細(xì)介紹了Android編寫文件瀏覽器簡(jiǎn)單實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11
Listview加載的性能優(yōu)化是如何實(shí)現(xiàn)的
在android開發(fā)中Listview是一個(gè)很重要的組件,它以列表的形式根據(jù)數(shù)據(jù)的長(zhǎng)自適應(yīng)展示具體內(nèi)容,用戶可以自由的定義listview每一列的布局,接下來通過本文給大家介紹Listview加載的性能優(yōu)化是如何實(shí)現(xiàn)的,對(duì)listview性能優(yōu)化相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧2016-01-01
使用RecyclerView添加Header和Footer的方法
RecyclerView雖然作為L(zhǎng)istView的替代者有著較好的性能提升,但是ListView的一些常用功能卻沒有提供,比如我們平時(shí)會(huì)經(jīng)常用到的addHeaderView,addFooterView,既然RecyclerView沒有提供這個(gè)方法,我們應(yīng)該如何為列表添加頭部和底部呢,接下來通過本文給大家介紹2016-03-03
Android實(shí)現(xiàn)帶動(dòng)畫效果的可點(diǎn)擊展開TextView
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)帶動(dòng)畫效果的可點(diǎn)擊展開TextView,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07
Android?Jetpack結(jié)構(gòu)運(yùn)用Compose實(shí)現(xiàn)微博長(zhǎng)按點(diǎn)贊彩虹效果
Compose在動(dòng)畫方面下足了功夫,提供了豐富的API。但也正由于API種類繁多,如果想一氣兒學(xué)下來,最終可能會(huì)消化不良,導(dǎo)致似懂非懂。結(jié)合例子學(xué)習(xí)是一個(gè)不錯(cuò)的方法,本文就帶大家邊學(xué)邊做,通過實(shí)現(xiàn)一個(gè)微博長(zhǎng)按點(diǎn)贊的動(dòng)畫效果,學(xué)習(xí)了解Compose動(dòng)畫的常見思路和開發(fā)技巧2022-07-07
android studio實(shí)現(xiàn)計(jì)算器
這篇文章主要為大家詳細(xì)介紹了android studio實(shí)現(xiàn)計(jì)算器的具體方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07
RecyclerView通過GridLayoutManager實(shí)現(xiàn)多樣式布局的示例
本篇文章主要介紹了RecyclerView通過GridLayoutManager實(shí)現(xiàn)多樣式布局的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-12-12
android實(shí)現(xiàn)視頻的加密和解密(使用AES)
本篇文章主要介紹了android實(shí)現(xiàn)視頻的加密和解密(使用AES),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-05-05

