[Interest] QtMultimedia::registerMediaFile
Jason H
jhihn at gmx.com
Fri Apr 3 20:16:55 CEST 2015
I take a photo and save it on the device, I need it to appear in the Gallery/on the MTP interface. I am creating the photos fine, if I reboot the device they show up in the gallery when I plug in my phone, and they show up in the MTP interface under Internal Storage/Pictures. They are visible in the adb shell as well.
I am trying to get Android to register or scan the file so that it appears in those areas in real-time. Realizing that stuff uses a private interfaces, I tried doing this (code below), but to no avail. I think registerFile does the same thing ultimately.
http://developer.android.com/reference/android/media/MediaScannerConnection.html#scanFile(java.lang.String, java.lang.String)
// file = "/storage/emulated/0/Pictures/Wounds/8ec45672-76d6-4260-bb10-5e9801e43167.jpg" or
// file = "/storage/emulated/legacy/Pictures/Wounds/8ec45672-76d6-4260-bb10-5e9801e43167.jpg"
void MediaRegister::registerFile(const QString& file)
{
#ifdef ANDROID
QAndroidJniObject string = QAndroidJniObject::fromString(file);
QAndroidJniObject::callStaticMethod<void>("android/media/MediaScannerConnection",
"scanFile","(Ljava/lang/String;Ljava/lang/String)V", string.object<jstring>(), 0);
qDebug() << Q_FUNC_INFO << file;
#endif
}
Any input on what I am doing wrong would be greatly appreciated. I don't see any thing other than my debug line in logcat, so there is no feedback from the function.
It would be cool (is there already a way to ) have Qt provide the registration function? That's what I thought the QtMultimedia::registerMediaFile function was for.
Thanks
> Sent: Friday, April 03, 2015 at 12:29 PM
> From: "Thiago Macieira" <thiago.macieira at intel.com>
> To: interest at qt-project.org
> Subject: Re: [Interest] QtMultimedia::registerMediaFile
>
> On Friday 03 April 2015 18:17:26 Jason H wrote:
> > I need to use the 'registerMediaFile' function from
> > https://qt.gitorious.org/qt/qtmultimedia/source/ecce937a054e4a96597cb13c40d
> > 216bddbd45891:src/plugins/android/jar/src/org/qtproject/qt5/android/multimed
> > ia/QtMultimediaUtils.java
> >
> > But I don't know how, since it is Java.
> >
> > Can someone provide an example?
>
> Are you writing a Java application for Android and asking how you can call
> that function?
>
> Or are you writing a C++ application for Android and asking how you can call
> that function?
>
> And what do you mean by "I need to use"? Why do you need to use that function?
> That function is in a plugin, it was never intended that you should be able to
> call it.
>
> This is probably an XY problem: you need to do X and you think that you can
> achieve that by doing Y, so you asked about Y ("I need to use.."). Please tell
> us about X.
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
> Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
More information about the Interest
mailing list