本文實例為大家分享了Android相機(jī)管理工具類的具體代碼,供大家參考,具體內(nèi)容如下
為嵐皋等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及嵐皋網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都做網(wǎng)站、網(wǎng)站設(shè)計、嵐皋網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
package com.utils.tools; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import com.shennongshi.dingdong.R; import com.shennongshi.dingdong.pztools.IntentConstant.RequestCode; import com.third.imageloader.ImageCache; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.os.Environment; import android.text.TextUtils; public class CameraUtils { private static final String PICTURES = "picture"; private static String IMG_PATH_NAME = ""; public static void getImageFromAlbum(Activity act) { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); act.startActivityForResult(intent, RequestCode.REQUEST_CODE_PICK_IMAGE); } public static void getImageFromCamera(Activity act) { String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { Intent getImageByCamera = new Intent("android.media.action.IMAGE_CAPTURE"); act.startActivityForResult(getImageByCamera, RequestCode.REQUEST_CODE_CAPTURE_CAMEIA); } else { XToaster.show(R.string.qqryjcrSDk); } } public static void createFile(Activity act) { if (TextUtils.isEmpty(IMG_PATH_NAME)) { String path = ImageCache.getDiskCacheDir(act, PICTURES).getAbsolutePath(); File file = new File(path); if (!file.exists()) file.mkdirs(); IMG_PATH_NAME = path + "/" + System.currentTimeMillis() + ".jpg"; } } public static boolean saveImage(Bitmap photo) { try { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(IMG_PATH_NAME, false)); photo.compress(Bitmap.CompressFormat.JPEG, 100, bos); bos.flush(); bos.close(); } catch (Exception e) { return false; } return true; } }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。