本文实例为大家分享了AndroID相机管理工具类的具体代码,供大家参考,具体内容如下
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; } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。
以上是内存溢出为你收集整理的Android相机管理工具类全部内容,希望文章能够帮你解决Android相机管理工具类所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)