Unsolved Screen capture for Android
-
Hi everyone
I need to screen capture on Android. I've tried grabWindow:
QPixmap desk = g_app->screens().at(0)->grabWindow( QDesktopWidget().winId() ); bool x = desk.save(path3.append("/screenshot.PNG"));
but x returned false. i tried to see QPixmap size:
QByteArray bytes; QBuffer buffer(&bytes); buffer.open(QIODevice::WriteOnly); desk.save(&buffer, "PNG"); qDebug() << "len " << buffer.size();
the output was len 0
any ideas?
alternatively, any Android class I can use using JNI or something similar?
thanks SO much for any help
Lior -
Hi and welcome to devnet,
What is the exact path you used to save the file ?
-
@Liorm said in Screen capture for Android:
hi and thanks
this is the path
QString path3 = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);which is evaluated to '/storage/emulated/0/Download'
but the main point is that the QPixmap is empty... buffer.size is 0
is grabWindow known to work in Android? i see conflicting reports
thanks!
-
@Liorm said in Screen capture for Android:
I need to screen capture on Android. I've tried grabWindow:
of a QWidget or QML application?
-
QDesktopWidget().winId()
that's wrong.Take a look at the QDesktopWidget documentation on how to properly get a QDesktopWidget object.
Note that I'm not sure what the result is on Android.