今天就跟大家聊聊有關(guān)怎么在Android應(yīng)用中實現(xiàn)一個頭像編輯功能,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

實現(xiàn)方法如下:
public static void startCamera(Fragment fragment){
File file=new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)+
File.separator+"user_icon.jpg");
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//intent隱式調(diào)用啟動拍照界面
intent.putExtra("return-data",false);//該屬性設(shè)置為false表示拍照后不會將數(shù)據(jù)返回到onResluet方法中(建議設(shè)置為false,這樣獲取的圖片會比較清晰)
ComponentName componentName=intent.resolveActivity(fragment.getContext().getPackageManager());
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));//該屬性設(shè)置的是拍照后圖片保存的位置
//防止app啟動意圖時崩潰
if (componentName!=null){
fragment.startActivityForResult(intent,Variable.request_camera_code);
}
}
文章名稱:怎么在Android應(yīng)用中實現(xiàn)一個頭像編輯功能-創(chuàng)新互聯(lián)
URL標(biāo)題:http://chinadenli.net/article30/dpsgso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、云服務(wù)器、虛擬主機、外貿(mào)建站、全網(wǎng)營銷推廣、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容