android截屏
来源:互联网 发布:jsp与php的区别 编辑:程序博客网 时间:2024/04/30 12:20
public void onShow(View v) {
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd_HH-mm-ss",
Locale.US);
String fname = Environment.getExternalStorageDirectory() + "/test_"
+ sdf.format(new Date()) + ".png";
FileOutputStream out = null;
View view = v.getRootView();
view.invalidate();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();
//ImageView iv=(ImageView) findViewById(R.id.ivShow);
//iv.setImageBitmap(bitmap);
if(bitmap != null){
Log.e("tag","bitmap got!");
try{
out = new FileOutputStream(fname);
bitmap.compress(Bitmap.CompressFormat.PNG,100,out);
}catch(Exception
e) {
e.printStackTrace();
}
try {
FileInputStream fis = new FileInputStream(fname);
bitmap = BitmapFactory.decodeStream(fis);
setShareContent(bitmap);
umController.openShare((Activity)context, false);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}else{
Toast.makeText(context, "分享失败", 5000).show();
Log.e("tag","bitmap is NULL!");
}
}
说明:地图截屏需要实现地图的监听方法。
0 0
- Android截屏
- android截屏
- android截屏
- android 截屏
- android截屏
- Android截屏
- ANDROID截屏
- android 截屏
- Android截屏
- android截屏
- Android截屏
- android 截屏
- android截屏
- android 截屏
- Android 截屏
- android截屏
- android 截屏
- android截屏
- Qt on_pushButton_clicked()的用法
- 正则验证js大全
- JAVA中三种URL连接方法
- leetcode oj java Excel Sheet Column Title
- netperf 与网络性能测量
- android截屏
- Android中延迟加载的问题
- 怎么使用互联网安全技能防身
- 程序存储问题
- linux学习教程(二)Linux基础(文件命令)
- python批量打多渠道包
- 导出Excel表格功能
- Oracle查询重复数据并删除,只保留一条记录
- Spark Streaming和Kafka整合开发指南