android截屏代码
来源:互联网 发布:梦里花落知多少全文txt 编辑:程序博客网 时间:2024/05/16 00:15
private Button m_btn;private MainActivity m_thisActv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); m_thisActv = this; m_btn = (Button)findViewById(R.id.button1); m_btn.setOnClickListener(new View.OnClickListener() { @Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubString fname = "mnt/sdcard/hello.png";View view = m_thisActv.getWindow().getDecorView();view.setDrawingCacheEnabled(true);view.buildDrawingCache();Bitmap bitmap = view.getDrawingCache();if (bitmap != null) {m_logTextString+="bitmap got!\n";m_texView.setText(m_logTextString);try{FileOutputStream out = new FileOutputStream(fname);bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);} catch(Exception e){e.printStackTrace();}} else{Log.d("myLog","bitmap == null");}}});}
记得配置权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
0 0
- Android代码截屏
- android截屏代码
- Android代码截屏
- Android代码截屏
- android截屏代码
- Android 代码截屏
- Android代码截屏
- android截屏代码
- android 代码截屏
- Android之截屏代码 .
- Android之截屏代码
- Android之截屏代码
- android 截屏代码段
- (转)Android代码截屏
- Android截屏关键代码
- android截屏代码实例
- android截屏代码实现方法
- android截屏代码:C++实现
- 如何写好一篇文章
- Codevs 数轴染色
- Android:控件WebView显示网页
- yii2 advanced版本dev和pro配置
- BH&BF&O的区别
- android截屏代码
- iOS9开发--(Content Blocker)Safari广告拦截详解
- 再次认识mvc,面试常用(2015年10月19日)
- poj 1775 Sum of Factorials 枚举子集
- sql语法练习(一)
- Android 如何隐藏应用程序的图标
- spring中IOC容器中的xml加载过程
- bootstrap-datetimepicker在ie8下报对象不支持"indexOf"属性或方法
- android 加密存储