Android中簡單調(diào)用圖片、視頻、音頻、錄音和拍照的方法
本文實(shí)例講述了Android中簡單調(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é)》
希望本文所述對大家Android程序設(shè)計(jì)有所幫助。
- Android編程錄音工具類RecorderUtil定義與用法示例
- Android編程實(shí)現(xiàn)錄音及保存播放功能的方法【附demo源碼下載】
- Android編程檢測手機(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 錄音與播放功能的簡單實(shí)例
- Android編程實(shí)現(xiàn)通話錄音功能的方法
- 利用libmp3lame實(shí)現(xiàn)在Android上錄音MP3文件示例
- Android錄音--AudioRecord、MediaRecorder的使用
- android 通過MediaRecorder實(shí)現(xiàn)簡單的錄音示例
- Android使用MediaRecorder實(shí)現(xiàn)錄音及播放
- Android錄音播放管理工具
- Android實(shí)現(xiàn)拍照、錄像、錄音代碼范例
- Android實(shí)現(xiàn)自制和播放錄音程序
- Android編程開發(fā)錄音和播放錄音簡單示例
- Android錄音mp3格式實(shí)例詳解
相關(guān)文章
Android編程中號(hào)碼匹配位數(shù)修改的方法
這篇文章主要介紹了Android編程中號(hào)碼匹配位數(shù)修改的方法,涉及Android編程中參數(shù)修改的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11Android使用ViewPager完成app引導(dǎo)頁
這篇文章主要為大家詳細(xì)介紹了Android使用ViewPager完成app引導(dǎo)頁,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-11-11如何利用adb卸載手機(jī)預(yù)裝軟件(系統(tǒng)軟件)
對于Android手機(jī)通常有很多不必要的預(yù)置軟件,但是又無法卸載,占用桌面有很難受,所以本次使用adb工具來實(shí)現(xiàn)從電腦命令來卸載或停用軟件,下面這篇文章主要給大家介紹了關(guān)于如何利用adb卸載手機(jī)預(yù)裝軟件(系統(tǒng)軟件)的相關(guān)資料,需要的朋友可以參考下2022-09-09Android實(shí)現(xiàn)可收縮和擴(kuò)展的TextView
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)可收縮和擴(kuò)展的TextView,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03android使用surfaceview+MediaPlayer播放視頻
這篇文章主要為大家詳細(xì)介紹了android使用surfaceview+MediaPlayer播放視頻,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-11-11