Android 获取截图 并将其保存到本地sd在卡路径
/**
* 获取当前屏幕和保存截图
*/
private void GetandSaveCurrentImage()
{
//1.构建Bitmap
WindowManager windowManager = getWindowManager();
Display display = windowManager.getDefaultDisplay();
int w = display.getWidth();
int h = display.getHeight(); Bitmap Bmp = Bitmap.createBitmap( w, h, Config.ARGB_8888 ); //2.获取屏幕
View decorview = this.getWindow().getDecorView();
decorview.setDrawingCacheEnabled(true);
Bmp = decorview.getDrawingCache(); String SavePath = getSDCardPath()+"/AndyDemo/ScreenImage"; //3.保存Bitmap
try {
File path = new File(SavePath);
//文件
String filepath = SavePath + "/Screen_1.png";
File file = new File(filepath);
if(!path.exists()){
path.mkdirs();
}
if (!file.exists()) {
file.createNewFile();
} FileOutputStream fos = null;
fos = new FileOutputStream(file);
if (null != fos) {
Bmp.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.flush();
fos.close(); Toast.makeText(CircleShareActivity.this, "截屏文件已保存至SDCard/AndyDemo/ScreenImage/下", Toast.LENGTH_LONG).show();
} } catch (Exception e) {
e.printStackTrace();
}
} /**
* 获取SDCard的文件夹路径功能
* @return
*/
private String getSDCardPath(){
File sdcardDir = null;
//推断SDCard是否存在
boolean sdcardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
if(sdcardExist){
sdcardDir = Environment.getExternalStorageDirectory();
}
return sdcardDir.toString();
}
Android 获取截图 并将其保存到本地sd在卡路径的更多相关文章
- php获取网页中图片并保存到本地
php获取网页中图片并保存到本地的代码,将网页中图片保存本地文件夹: save_img("http://www.jbxue.com" ?>
- php获取网页中图片并保存到本地的代码
php获取网页中图片并保存到本地的代码,将网页中图片保存本地文件夹: <?php /** * 获取网页中图片,并保存至本地 * by www.jbxue.com */ header(" ...
- android:http下载文件并保存到本地或SD卡
想把文件保存到SD卡中,一定要知道SD卡的路径,获取SD卡路径: Environment.getExternalStorageDirectory() 另外,在保存之前要判断SD卡是否已经安装好,并且可 ...
- Android -- 获取网络数据并将数据存到本地数据库中
public static final int downloadDone = 1; // 用户model数组 ArrayList<Loginer> loginers = new Array ...
- android调用系统相机拍照并保存在本地
import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import j ...
- Android开发----使用 Room 将数据保存到本地数据库
Room介绍以及不使用SQLite的原因 Room 在 SQLite 上提供了一个抽象层,以便在充分利用 SQLite 的强大功能的同时,能够流畅地访问数据库. 处理大量结构化数据的应用可极大地受益于 ...
- android中使用Http下载文件并保存到本地SD卡
1.AndroidMainfest.xml中设置权限 <uses-permission android:name="android.permission.INTERNET"& ...
- 如何获取网页验证码图片并保存到本地(Java实现) [问题点数:40分,结帖人lanxuezaipiao]
http://bbs.csdn.net/topics/390426978 public static String readCheckImage(HashMap<String, String&g ...
- wpf 获取Image的图片并保存到本地
XMAL代码如下: <Image Name="ImageToSave" Source="Images/pic_bg.png" Grid.RowSpan=& ...
随机推荐
- matlab入门 蜂窝阵列
B{1,1}=[1,2]; B{1,2}='kitty'; B B = [1x2 double] 'kitty' celldisp(B) B{1} = 1 2 B{2} = ...
- KMP算法(转)
KMP算法 在介绍KMP算法之前,先介绍一下BF算法. 一.BF算法 BF算法是普通的模式匹配算法,BF算法的思想就是将目标串S的第一个字符与模式串P的第一个字符进行匹配,若相等,则继续比较S的第二个 ...
- iOS类别(Category)和扩展(Extension,匿名类)
Category在iOS在开发常用. 特别是对于系统扩展上课时间.我们不能继承系统类.直接添加到系统类方法,最大程度上体现Objective-C动态语言特征. #import @interface N ...
- jQuery Easy UI Accordion(可伸缩的面板)包
Accordion 可伸缩的面板组件.基于panel,示为以下的比率: <!doctype html> <html lang="en"> <head& ...
- SQLserver创建与主外键的看法
一个.背景 最初研究的相关内容数据库.仅仅是正式.从来没有练过,只能慢慢漂流,现在做的客房时,,非常多的知识需要使用视图,慢的实践. 视图:我理解的就是一张表.它把我们所须要的某个表或某几个表中的部分 ...
- lua转让C++书面DLL达到“热更新”
原创作品,请注明出处转载CSDN:http://blog.csdn.net/relar/article/details/38084689 开发游戏server往往有"热更新"的需求 ...
- NYOJ 330 一个简单的数学
一个简单的数学题 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描写叙述 zyc近期迷上了数学,一天,dj想出了一道数学题来难住他.算出1/n,但zyc一时答不上来希望大家能 ...
- 【iOS发展-70】点菜系统案例:使用文本框inputView和inputAccessoryView串联UIPickerView、UIDatePicker和UIToolBar
(1)效果 (2)先在storyboard中设计界面,然后源码(直接在ViewController中码) #import "ViewController.h" @interface ...
- 经典弹出层Colorbox - a jQuery lightbox
Colorbox - a jQuery lightbox A lightweight customizable lightbox plugin for jQuery Fork me on GitHub ...
- SVN & Git (一)
(一)SVN的使用.CornerStone图形化管理工具! SVN是Subversion的简称,是一个开放源代码的版本控制系统,相较于RCS.CVS,它采用了分支管理系统,它的设计目标就是取代CVS. ...