讨论:如何用android编写“截屏”的代码呢?就像windows操作系统截屏一样? 欢迎大家讨论,这个话题很有趣! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个不清楚,估计又涉及到底层了。越来越觉得google对开发者限制太多了,而且api文档做的也不好。在apiDoc中,想搜索个方法名 都没这个功能。 涉及到底层,不过DDMS可以截图或者使用一个软件 APK安装器,下载地址 http://www.crsky.com/soft/16759.html 估计手机上没有root权限不可以吧 经常有xml node文档查不到 如layer-list clip很多函数文档上啥也没有 如Surface.freeze也有可能是为了照顾低性能系统 framework跟sun和ms的没法比没有开放C接口 搞的大家都是看源码猜 且c层代码经常大规模改动 也在研究这个问题,就Google到这里来了……不知道OpenGL ES有没有这方面的接口。 直接用命令行即可。不过需要root 已经有这样的APK可以下载了,我用过,这个APK自带了一个su,复制到/system/xbin下面,覆盖掉之前那个,并修改权限4755就可以用了,很方便。 直接取framebuffer(有一个路径)中的内容应该就可以了。 源码里面有对应的实现,可以看看adb tool的源码。 android 里很少有机型是支持截图软件的说是为了保护用户隐私,纠结死 public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); currentView = findViewById(R.id.screen); clickBtn = findViewById(R.id.click_button); clickBtn.setOnClickListener(this); } public void onClick(View v){ View screen = currentView.getRootView(); System.out.println("Root view"); screen.setDrawingCacheEnabled(true); Bitmap shot = screen.getDrawingCache(); if(shot != null) System.out.println("shot is not null"); FileOutputStream fos = null; try { fos = new FileOutputStream(pathname); if(fos != null){ shot.compress(Bitmap.CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); } }catch (FileNotFoundException e){ e.printStatckTrace(); }catch (IOException e){ e.printStatckTrace(); } } 楼上,这个只能对view管用,但是对整个window的话,就无解~~ 如何将apk安装包转化为完整的可视代码? 菜鸟提问关于NFC代码的问题 蓝牙打印项目里socket.connect()连接不上啊,大婶们99 安卓手机2.1x系统用第三方播放器看视频会出现卡顿,花屏现象,为什么? wallpaperManager.setBitmap 请高手看一下 发福利了~~ listview多选 有没有可能这样布局:比如TextView的位置距屏幕左边4分之一? 关于ITelephony中getCellLocation返回结果转化的问题 android语音识别求教。 如何实现,在服务端下载到手机客户端的视频,这样的播放器,边下载边播放
越来越觉得google对开发者限制太多了,而且api文档做的也不好。
在apiDoc中,想搜索个方法名 都没这个功能。
很多函数文档上啥也没有 如Surface.freeze
也有可能是为了照顾低性能系统 framework跟sun和ms的没法比
没有开放C接口 搞的大家都是看源码猜 且c层代码经常大规模改动
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
currentView = findViewById(R.id.screen);
clickBtn = findViewById(R.id.click_button);
clickBtn.setOnClickListener(this);
} public void onClick(View v){
View screen = currentView.getRootView();
System.out.println("Root view");
screen.setDrawingCacheEnabled(true);
Bitmap shot = screen.getDrawingCache();
if(shot != null)
System.out.println("shot is not null"); FileOutputStream fos = null;
try {
fos = new FileOutputStream(pathname);
if(fos != null){
shot.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
}
}catch (FileNotFoundException e){
e.printStatckTrace();
}catch (IOException e){
e.printStatckTrace();
}
}