我想以编程方式截取Android设备的屏幕截图。以屏幕截图(以编程方式)
我知道这个问题已被问了很多次。我知道有两种方法可以做到这一点。
- 使用截图库(但我越来越黑屏)。
从帧缓冲区获取数据从
\dev\graphics\fb0
生根(但它总是0字节,我不知道设备的当前屏幕截图存储的确切位置)。我首选的要求也越来越好框架rate.My代码public 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); } } }); }'
Android没有内置的截图库。你在说什么图书馆? – 2013-02-27 16:58:21
Linux上的路径分隔符是'/'not \。 – m0skit0 2013-02-27 16:59:19
你是在谈论以编程方式获取屏幕截图,还是仅仅使用其他应用程序,或者从Eclipse或...? – Phil 2013-02-27 17:02:14