Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to send SMS in android?

How to send SMS in android?

Scheduled Pinned Locked Moved Mobile and Embedded
36 Posts 12 Posters 5.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on 20 May 2019, 10:37 last edited by
    #1

    Hi!
    How to send SMS in android?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 May 2019, 11:36 last edited by
      #2

      Hi,

      Did you try to look up the Android API ? A quick search turns out SmsManager.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Mikeeeeee
        wrote on 20 May 2019, 11:57 last edited by
        #3

        How in Qt to connect to the Android API and use some function, for example createAppSpecificSmsToken (PendingIntent intent)?

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on 20 May 2019, 14:40 last edited by
          #4

          Use Qt Android Extras helpers. Also you can read about here (from first to last episode).

          1 Reply Last reply
          2
          • S Offline
            S Offline
            Shrinidhi Upadhyaya
            wrote on 21 May 2019, 05:30 last edited by
            #5

            @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]

            Shrinidhi Upadhyaya.
            Upvote the answer(s) that helped you to solve the issue.

            1 Reply Last reply
            3
            • M Offline
              M Offline
              Mikeeeeee
              wrote on 21 May 2019, 10:41 last edited by Mikeeeeee
              #6

              If I add QT + = androidextras, I get an error: Unknown module (s) in QT: androidextras

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Shrinidhi Upadhyaya
                wrote on 21 May 2019, 10:51 last edited by
                #7

                Hi @Mikeeeeee , you need to add like this:-

                android: QT += androidextras
                

                Shrinidhi Upadhyaya.
                Upvote the answer(s) that helped you to solve the issue.

                1 Reply Last reply
                3
                • M Offline
                  M Offline
                  Mikeeeeee
                  wrote on 21 May 2019, 13:44 last edited by
                  #8

                  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>

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 21 May 2019, 21:03 last edited by
                    #9

                    Might be a silly question but are you building that with your Qt Android kit ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Mikeeeeee
                      wrote on 22 May 2019, 08:35 last edited by
                      #10

                      MinGW does not compile, Clang compiles. Thanks.

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 22 May 2019, 09:19 last edited by
                        #11

                        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.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        2
                        • M Offline
                          M Offline
                          Mikeeeeee
                          wrote on 22 May 2019, 13:36 last edited by
                          #12

                          How to call a method in Qt from java SmsManager::createAppSpecificSmsTokenWithPackageinfo(String prefixes, PendingIntent intent)

                          J 1 Reply Last reply 22 May 2019, 13:56
                          0
                          • M Mikeeeeee
                            22 May 2019, 13:36

                            How to call a method in Qt from java SmsManager::createAppSpecificSmsTokenWithPackageinfo(String prefixes, PendingIntent intent)

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 22 May 2019, 13:56 last edited by
                            #13

                            @Mikeeeeee Take a look at https://doc.qt.io/qt-5/qandroidjniobject.html

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            1
                            • M Offline
                              M Offline
                              Mikeeeeee
                              wrote on 22 May 2019, 15:48 last edited by
                              #14

                              Will this option work, or should we do it differently?

                                  QAndroidJniObject testSms;
                                  testSms.callMethod< jint > ("createAppSpecificSmsTokenWithPackageInfo(32133)");
                              
                              P J 2 Replies Last reply 22 May 2019, 16:22
                              0
                              • M Mikeeeeee
                                22 May 2019, 15:48

                                Will this option work, or should we do it differently?

                                    QAndroidJniObject testSms;
                                    testSms.callMethod< jint > ("createAppSpecificSmsTokenWithPackageInfo(32133)");
                                
                                P Offline
                                P Offline
                                Pablo J. Rogina
                                wrote on 22 May 2019, 16:22 last edited by
                                #15

                                @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...

                                Upvote the answer(s) that helped you solve the issue
                                Use "Topic Tools" button to mark your post as Solved
                                Add screenshots via postimage.org
                                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                                1 Reply Last reply
                                2
                                • M Offline
                                  M Offline
                                  Mikeeeeee
                                  wrote on 22 May 2019, 17:21 last edited by
                                  #16

                                  It doesn't work. How can this be fixed to work?

                                  1 Reply Last reply
                                  0
                                  • M Mikeeeeee
                                    22 May 2019, 15:48

                                    Will this option work, or should we do it differently?

                                        QAndroidJniObject testSms;
                                        testSms.callMethod< jint > ("createAppSpecificSmsTokenWithPackageInfo(32133)");
                                    
                                    J Offline
                                    J Offline
                                    JonB
                                    wrote on 22 May 2019, 18:19 last edited by JonB
                                    #17

                                    @Mikeeeeee

                                        QAndroidJniObject 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 that methodName 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 pass 32133 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?

                                    1 Reply Last reply
                                    2
                                    • M Offline
                                      M Offline
                                      Mikeeeeee
                                      wrote on 23 May 2019, 11:30 last edited by
                                      #18

                                      The SmsManager class has a getcarrierconfigvalues() function without an argument.
                                      This code also generates an error:

                                          QAndroidJniObject testSms;
                                          testSms.callMethod< jint > ("getCarrierConfigValues()");
                                      
                                      J J 2 Replies Last reply 23 May 2019, 12:00
                                      0
                                      • M Mikeeeeee
                                        23 May 2019, 11:30

                                        The SmsManager class has a getcarrierconfigvalues() function without an argument.
                                        This code also generates an error:

                                            QAndroidJniObject testSms;
                                            testSms.callMethod< jint > ("getCarrierConfigValues()");
                                        
                                        J Offline
                                        J Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on 23 May 2019, 12:00 last edited by
                                        #19

                                        @Mikeeeeee said in How to send SMS in android?:

                                        generates an error

                                        Please post the error

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        1
                                        • M Offline
                                          M Offline
                                          Mikeeeeee
                                          wrote on 23 May 2019, 12:12 last edited by
                                          #20

                                          "org.qt project.example.smsTest" crashed.

                                          J KroMignonK 2 Replies Last reply 23 May 2019, 12:21
                                          0

                                          7/36

                                          21 May 2019, 10:51

                                          topic:navigator.unread, 29
                                          • Login

                                          • Login or register to search.
                                          7 out of 36
                                          • First post
                                            7/36
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved