8#include <QDesktopServices>
10#include <QMimeDatabase>
11#include <QtCore/QJniObject>
12#include <QtCore/qcoreapplication.h>
13#include <QtCore/qscopedvaluerollback.h>
21 m_actionView = QJniObject::getStaticObjectField(
"android/content/Intent",
"ACTION_VIEW",
32 context.callObjectMethod(
"getIntent",
"()Landroid/content/Intent;");
49 if (
url == m_handlingUrl)
69 QAndroidApplication::context(),
url.object<jstring>(), mimeString.object<jstring>());
73 return openUrl(QJniObject::fromString(
url.
toString()));
77 const auto appId =
context.callMethod<jstring>(
"getPackageName").
toString();
78 const auto providerName = QJniObject::fromString(appId +
".qtprovider"_L1);
80 const auto urlPath = QJniObject::fromString(
url.
path());
81 const auto urlFile =
QJniObject(QtJniTypes::className<QtJniTypes::File>(),
82 urlPath.object<jstring>());
84 const auto fileProviderUri = QJniObject::callStaticMethod<QtJniTypes::UriType>(
85 QtJniTypes::className<QtJniTypes::FileProvider>(),
"getUriForFile",
86 QAndroidApplication::context(), providerName.object<jstring>(),
87 urlFile.object<QtJniTypes::FileType>());
89 if (fileProviderUri.isValid())
90 return openUrl(fileProviderUri.callMethod<jstring>(
"toString"));
111 const QString action = jniIntent.callObjectMethod<jstring>(
"getAction").
toString();
112 if (action != m_actionView)
static bool openUrl(const QUrl &url)
Opens the given url in the appropriate Web browser for the user's desktop environment,...
QMimeType mimeTypeForUrl(const QUrl &url) const
Returns a MIME type for url.
QString name
the name of the MIME type
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString scheme() const
Returns the scheme of the URL.
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
Combined button and popup list for selecting options.
Q_CORE_EXPORT void registerNewIntentListener(NewIntentListener *listener)
Q_CORE_EXPORT QtJniTypes::Context context()
jclass applicationClass()
Q_DECLARE_JNI_TYPE(File, "Ljava/io/File;")
static QString fileScheme()
QUrl url("example.com")
[constructor-url-reference]
application x qt windows mime
[2]
char * toString(const MyType &t)
[31]