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",
28 if (QNativeInterface::QAndroidApplication::isActivityContext()) {
34 context.callObjectMethod(
"getIntent",
"()Landroid/content/Intent;");
52 if (
url == m_handlingUrl)
72 QAndroidApplication::context(),
url.object<jstring>(), mimeString.object<jstring>());
76 return openUrl(QJniObject::fromString(
url.
toString()));
80 const auto appId =
context.callMethod<jstring>(
"getPackageName").
toString();
81 const auto providerName = QJniObject::fromString(appId +
".qtprovider"_L1);
83 const auto urlPath = QJniObject::fromString(
url.
path());
84 const auto urlFile =
QJniObject(QtJniTypes::Traits<QtJniTypes::File>::className(),
85 urlPath.object<jstring>());
87 const auto fileProviderUri = QJniObject::callStaticMethod<QtJniTypes::UriType>(
88 QtJniTypes::Traits<QtJniTypes::FileProvider>::className(),
"getUriForFile",
89 QAndroidApplication::context(), providerName.object<jstring>(),
90 urlFile.object<QtJniTypes::FileType>());
92 if (fileProviderUri.isValid())
93 return openUrl(fileProviderUri.callMethod<jstring>(
"toString"));
114 const QString action = jniIntent.callObjectMethod<jstring>(
"getAction").
toString();
115 if (action != m_actionView)
119 QScopedValueRollback<QUrl> rollback(m_handlingUrl,
url);
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 noexcept
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()
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
static QString fileScheme()
QUrl url("example.com")
[constructor-url-reference]
application x qt windows mime
[2]
char * toString(const MyType &t)
[31]