How to send SMS in android?
-
wrote on 20 May 2019, 10:37 last edited by
Hi!
How to send SMS in android? -
Hi,
Did you try to look up the Android API ? A quick search turns out SmsManager.
-
wrote on 20 May 2019, 11:57 last edited by
How in Qt to connect to the Android API and use some function, for example createAppSpecificSmsToken (PendingIntent intent)?
-
Use Qt Android Extras helpers. Also you can read about here (from first to last episode).
-
wrote on 21 May 2019, 05:30 last edited by
@Mikeeeeee , you can write a java class which contains the function to send the sms, and after that you can use the QtAndroid and QAndroidJniEnvironment in your cpp class and call the function defined in your java class.
Something like this:-QtAndroid::androidActivity().callMethod<void>("sendSMS");
I had used "textLocal" (sms platform) in a project i was working on and it worked really nice, so they have few API's which you can make use of.If you want the code for that please have a look at this[http://api.textlocal.in/docs/sendsms].
For more information about QtAndroid[https://doc.qt.io/qt-5/qtandroid.html] and QAndroidJniEnvironment[https://doc.qt.io/qt-5/qandroidjnienvironment.html]
-
wrote on 21 May 2019, 10:41 last edited by Mikeeeeee
If I add QT + = androidextras, I get an error: Unknown module (s) in QT: androidextras
-
wrote on 21 May 2019, 10:51 last edited by
Hi @Mikeeeeee , you need to add like this:-
android: QT += androidextras
-
wrote on 21 May 2019, 13:44 last edited by
In .pro the file was compiled. If I add #include <Qt Android Extras> I get errors: 'QtAndroidExtras' file not found , QtAndroidExtras: No such file or directory
#include <QtAndroidExtras> -
Might be a silly question but are you building that with your Qt Android kit ?
-
wrote on 22 May 2019, 08:35 last edited by
MinGW does not compile, Clang compiles. Thanks.
-
That has nothing to do with your error. You were using a Qt build that was not for Android, likely your desktop build.
MinGW is unrelated to the Qt Android version. The compiler is provided by the Android NDK.
-
wrote on 22 May 2019, 13:36 last edited by
How to call a method in Qt from java SmsManager::createAppSpecificSmsTokenWithPackageinfo(String prefixes, PendingIntent intent)
-
How to call a method in Qt from java SmsManager::createAppSpecificSmsTokenWithPackageinfo(String prefixes, PendingIntent intent)
@Mikeeeeee Take a look at https://doc.qt.io/qt-5/qandroidjniobject.html
-
wrote on 22 May 2019, 15:48 last edited by
Will this option work, or should we do it differently?
QAndroidJniObject testSms; testSms.callMethod< jint > ("createAppSpecificSmsTokenWithPackageInfo(32133)");
-
Will this option work, or should we do it differently?
QAndroidJniObject testSms; testSms.callMethod< jint > ("createAppSpecificSmsTokenWithPackageInfo(32133)");
wrote on 22 May 2019, 16:22 last edited by@Mikeeeeee said in How to send SMS in android?:
Will this option work
Have you already tried? Trial and error is a way to learn...
-
wrote on 22 May 2019, 17:21 last edited by
It doesn't work. How can this be fixed to work?
-
Will this option work, or should we do it differently?
QAndroidJniObject testSms; testSms.callMethod< jint > ("createAppSpecificSmsTokenWithPackageInfo(32133)");
wrote on 22 May 2019, 18:19 last edited by JonBQAndroidJniObject testSms; testSms.callMethod< jint > ("createAppSpecificSmsTokenWithPackageInfo(32133)");
With the warning that I know absolutely nothing about this:
You are using the overload https://doc.qt.io/qt-5/qandroidjniobject.html#callMethod,
callMethod(const char *methodName)
. It may well be thatmethodName
has to be a method name,"createAppSpecificSmsTokenWithPackageInfo(32133)"
is a full function call. You may have to use overload https://doc.qt.io/qt-5/qandroidjniobject.html#callMethod-1,callMethod(const char *methodName, const char *sig, ...)
, and specify the function signature and pass32133
as parameter, in order to call functions with parameters?Have you/can you test if you can call a method which does not take any parameters, does that work OK?
-
wrote on 23 May 2019, 11:30 last edited by
The SmsManager class has a getcarrierconfigvalues() function without an argument.
This code also generates an error:QAndroidJniObject testSms; testSms.callMethod< jint > ("getCarrierConfigValues()");
-
The SmsManager class has a getcarrierconfigvalues() function without an argument.
This code also generates an error:QAndroidJniObject testSms; testSms.callMethod< jint > ("getCarrierConfigValues()");
-
wrote on 23 May 2019, 12:12 last edited by
"org.qt project.example.smsTest" crashed.
6/36