I would like to implement some sort of remote assistance tool (like vnc) for Android. Is there the possibility to capture a screen programmatically on the device?
You can try the following library: http://code.google.com/p/android-screenshot-library/ Android Screenshot Library (ASL) enables to programmatically capture screenshots from Android devices without requirement of having root access privileges. Instead, ASL utilizes a native service running in the background, started via the Android Debug Bridge (ADB) once per device boot.
put it in onClick ..
Bitmap bitmap = takeScreenshot();
saveBitmap(bitmap);
and write funtcion..
public Bitmap takeScreenshot() {
View rootView = findViewById(android.R.id.content).getRootView();
rootView.setDrawingCacheEnabled(true);
return rootView.getDrawingCache();
}
public void saveBitmap(Bitmap bitmap) {
File imagePath = new File(Environment.getExternalStorageDirectory() + "/screenshot.png");
FileOutputStream fos;
try {
fos = new FileOutputStream(imagePath);
bitmap.compress(CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
Log.e("GREC", e.getMessage(), e);
} catch (IOException e) {
Log.e("GREC", e.getMessage(), e);
}
}
Something like that might work for you:
View v = view.getRootView();
v.setDrawingCacheEnabled(true);
Bitmap b = v.getDrawingCache();
I think its possible in kitkat using the adb command for screen capture. You can use this command to record screen as a video
adb shell screenrecord /sdcard/demo.mp4
You can find more details here
you can execute the adb command from your app. Check the answer here
The VNC-type remote tol does exist for "SOME" android devices (mainly Samsung):
TeamViewer QuickSupport
https://play.google.com/store/apps/details?id=com.teamviewer.quicksupport.market
Dos anyone knows how that tool gets screen capturing, and why it supports only limited set of devices?
There is a long discussion of this on android-developers, but the short answer is: You can't programatically take a screenshot of an android device's screen at the moment, unless
The Android Manifest permission READ_FRAME_BUFFER exists (see the api docs here), but can presently only be used by system applications. There are various reasons for this, one being that it is a security risk. If an background can take a screenshot of the phone's screen at any time, then people could use OCR techniques to sniff user's passwords as they were typed in, among other private information.
So no, a VNC application is not possible at the moment without root. To take a screenshot from your computer (while the phone is plugged in via usb) you can use DDMS.