Commit 015f5365 authored by Volker Krause's avatar Volker Krause
Browse files

Use the new method wrappers for Intent

parent 96c50444
......@@ -27,57 +27,12 @@ Intent::Intent(const QAndroidJniObject &intent)
Intent::~Intent() = default;
void Intent::addCategory(const QAndroidJniObject &category)
m_intent.callObjectMethod("addCategory", Jni::signature<android::content::Intent(java::lang::String)>(), category.object());
void Intent::addFlags(jint flags)
m_intent.callObjectMethod("addFlags", Jni::signature<android::content::Intent(int)>(), flags);
QUrl Intent::getData() const
if (!m_intent.isValid()) {
return {};
const auto uri = m_intent.callObjectMethod("getData", Jni::signature<android::net::Uri()>());
return Uri::toUrl(uri);
QString Intent::getAction() const
return m_intent.callObjectMethod("getAction", Jni::signature<java::lang::String()>()).toString();
void Intent::setAction(const QAndroidJniObject &action)
m_intent.callObjectMethod("setAction", Jni::signature<android::content::Intent(java::lang::String)>(), action.object());
void Intent::setData(const QUrl& url)
const auto uri = Uri::fromUrl(url);
void Intent::setData(const QAndroidJniObject& uri)
m_intent.callObjectMethod("setData", Jni::signature<android::content::Intent(android::net::Uri)>(), uri.object());
QString Intent::getType() const
return m_intent.callObjectMethod("getType", Jni::signature<java::lang::String()>()).toString();
void Intent::setType(const QString &type)
Intent::operator QAndroidJniObject() const
m_intent.callObjectMethod("setType", Jni::signature<android::content::Intent(java::lang::String)>(), QAndroidJniObject::fromString(type).object());
return m_intent;
Intent::operator QAndroidJniObject() const
QAndroidJniObject Intent::handle() const
return m_intent;
......@@ -10,8 +10,10 @@
#include "kandroidextras_export.h"
#include <KAndroidExtras/AndroidTypes>
#include <KAndroidExtras/JniMethod>
#include <KAndroidExtras/JniProperty>
#include <KAndroidExtras/JavaTypes>
#include <KAndroidExtras/Uri>
#include <QAndroidJniObject>
......@@ -34,23 +36,22 @@ public:
/** Add a category to the intent. */
void addCategory(const QAndroidJniObject &category);
JNI_METHOD(android::content::Intent, addCategory, java::lang::String)
/** Add flags to this intent. */
void addFlags(jint flags);
JNI_METHOD(android::content::Intent, addFlags, jint)
/** Returns the data of this intent. */
QUrl getData() const;
JNI_METHOD(android::net::Uri, getData)
/** Get the intent action. */
QString getAction() const;
JNI_METHOD(java::lang::String, getAction)
/** Sets the action of the intent. */
void setAction(const QAndroidJniObject &action);
JNI_METHOD(android::content::Intent, setAction, java::lang::String)
/** Set the data URL of this intent. */
void setData(const QUrl &url);
void setData(const QAndroidJniObject &uri);
JNI_METHOD(android::content::Intent, setData, android::net::Uri)
/** Returns the mimetype of this intent. */
QString getType() const;
JNI_METHOD(java::lang::String, getType)
/** Set the mime type for this intent. */
void setType(const QString &type);
JNI_METHOD(android::content::Intent, setType, java::lang::String)
/** Read extra intent data. */
QString getStringExtra(const QAndroidJniObject &name) const;
......@@ -64,6 +65,7 @@ public:
/** Implicit conversion to an QAndroidJniObject. */
operator QAndroidJniObject() const;
QAndroidJniObject handle() const;
/** Action constant for create document intents. */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment