我想以編程方式截取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