it is easy to this code
Bitmap bitmap;
View v1 = MyView.getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
and it works great , but this is the case if there is activity.
How can I take a screenshot from service ?
my goal to take a screenshot ones in a hour ,e.i to to take screen shut every hour for example in 12 then in 1 then in 2 .... and so on
To capture ScreenShot for your activity you have to need a View
of your activity, and which one is not present in your service so you have to make a TimerTask which will call your activity at every hour and your activity responding it to with current appear view and you can capture the ScreenShot
from that. (I think this one is only solution for your problem.)
Or If you want to take a ScreenShot of your current device screen (any application) then you have to root permission, and read framebuffer
for that which will give raw data of current screen then convert it to bitmap or any picture file you can do it in your service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With