How to send SMS in android?
Locked
Unsolved
Mobile and Embedded
-
Hi!
How to send SMS in android?
Tried to do so, but it does not work:void MainWindow::on_testButton_clicked() { //QAndroidJniObject testSms; //testSms.callMethod< jint > ("getCarrierConfigValues()"); sendSMS("+7235235", "test text"); } void MainWindow::sendSMS(const QString& phoneNumber, const QString& message) { QtAndroid::runOnAndroidThreadSync([phoneNumber, message] { // get the Qt android activity QAndroidJniObject activity = QtAndroid::androidActivity(); if (activity.isValid()){ // get the default SmsManager QAndroidJniObject mySmsManager = QAndroidJniObject::callStaticObjectMethod("android/telephony/SmsManager", "getDefault", "()Landroid/telephony/SmsManager;" ); // get phone number & text from UI and convert to Java String QAndroidJniObject myPhoneNumber = QAndroidJniObject::fromString(phoneNumber); QAndroidJniObject myTextMessage = QAndroidJniObject::fromString(message); QAndroidJniObject scAddress = NULL; QAndroidJniObject sentIntent = NULL; QAndroidJniObject deliveryIntent = NULL; // call the java function: // public void SmsManager.sendTextMessage(String destinationAddress, // String scAddress, String text, // PendingIntent sentIntent, PendingIntent deliveryIntent) // see: http://developer.android.com/reference/android/telephony/SmsManager.html mySmsManager.callMethod<void>("sendTextMessage", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;)V", myPhoneNumber.object<jstring>(), scAddress.object<jstring>(), myTextMessage.object<jstring>(), NULL, NULL ); } else { qDebug() << "Something wrong with Qt activity..."; } }); }
-
@Mikeeeeee why are double posting? You've already started the same exact thread 3 weeks ago or so...
-
Locking topic as duplicate.