将ImageView中的图片保存到本地相册

时间:2014-10-27 12:48:42   收藏:0   阅读:265
private void SaveImageToSysAlbum() {
		if (FileUtil.isSdCardExist()) {
			BitmapDrawable bmpDrawable = (BitmapDrawable)mFullImageView.getDrawable();
			Bitmap bmp = bmpDrawable.getBitmap();
			if (bmp != null) {
				try {
					ContentResolver cr = getContentResolver();
					String url = MediaStore.Images.Media.insertImage(cr, bmp,
							String.valueOf(System.currentTimeMillis()), "");
					Toast.makeText(this, getString(R.string.save_succ), Toast.LENGTH_SHORT).show();

				} catch (Exception e) {
					e.printStackTrace();
				}
			}else {
				Toast.makeText(this, getString(R.string.no_iamge_save_fail), Toast.LENGTH_SHORT).show();
			}
		}else {
			Toast.makeText(this, getString(R.string.no_sdcard_save_fail), Toast.LENGTH_SHORT).show();
		}
		sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
	}

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!