问题描述
我想借此Android设备的屏幕截图编程。
我知道这个问题已经被问过很多times.I是知道的两种方式来做到这一点。
- 使用截图库(但我越来越黑屏所有的时间)。
-
正从帧缓冲数据与
\\ dev的生根\\图形\\ FB0
(但它始终是0字节,我不知道确切的位置,当前屏幕截图装置的存储)。我的preferred要求也越来越好框架rate.My code是公共无效的onCreate(捆绑savedInstanceState)
{
super.onCreate(savedInstanceState);
的setContentView(R.layout.main); 意向意图=新的Intent();
intent.setClass(这一点,ScreenshotService.class);
bindService(意向,新ServiceConnection(){ @覆盖
公共无效onServiceDisconnected(组件名名)
{ }
@覆盖
公共无效onServiceConnected(组件名名称,服务的IBinder){
尝试{
ASL = IScreenshotProvider.Stub.asInterface(服务);
}赶上(例外前){
Log.e(errrorrrrrrrrrrrrr,errrorrrrrrrrrrr,前);
}
}
},Context.BIND_AUTO_CREATE);
按钮B1 =(按钮)this.findViewById(R.id.widget33);
b1.setOnClickListener(新OnClickListener(){ 公共无效的onClick(查看视图)
{
尝试{
asl.takeScreenshot();
}赶上(RemoteException的前){
Log.e(nnnnerrrrrrrrrrrrrr,errrrrrrrrrrrrr,前);
}
}
});
}
不要发布超过一次一个问题了。
您可以使用以下code得到您的视图的绘图缓存:
view.setDrawingCacheEnabled(真);
view.buildDrawingCache();
位图B1 = view.getDrawingCache();
I would like to take a screenshot of an Android device programmatically.
I know this question has been asked many times.I am aware of two ways to do it.
- Using screenshot library(But I am getting black screen all the time).
getting data from frame buffer with rooting from
\dev\graphics\fb0
(But it is always 0 byte and I do not know exact location where current screenshot of device is stored). My preferred requirement is getting better frame rate.My code ispublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent intent = new Intent(); intent.setClass(this, ScreenshotService.class); bindService (intent, new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { } @Override public void onServiceConnected(ComponentName name, IBinder service) { try { asl = IScreenshotProvider.Stub.asInterface(service); } catch (Exception ex) { Log.e("errrorrrrrrrrrrrrr","errrorrrrrrrrrrr", ex); } } }, Context.BIND_AUTO_CREATE); Button b1=(Button) this.findViewById(R.id.widget33); b1.setOnClickListener(new OnClickListener() { public void onClick(View view) { try { asl.takeScreenshot(); } catch (RemoteException ex) { Log.e("nnnnerrrrrrrrrrrrrr","errrrrrrrrrrrrr",ex); } } }); }'
Dont post one question more than one time.
You can get the drawing cache of your view using the following code:
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap b1 = view.getDrawingCache();
这篇关于以屏幕截图(编程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!