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); } } }); }'