2 years ago

#45326

test-img

Buddu Edgar

Gluon Attach Service. SMS Not Sent

following the steps gluonfx attach service between graalvm and android , I was able to do the messaging defined under

    public class AndroidSmsService implements SmsService { ...
    
    @Override
    public void sendSms(Message message) {
        if (message != null) {
            _logger.log(Level.INFO, "AndroidSmsService#sendSms phone: {0}, sms : {1} ", new Object[]{message.getPhone(), message.getSms()});
            String phone = message.getPhone();
            String sms = message.getSms();
            if (phone != null && phone.length() > 0 && sms != null && sms.length() > 0) {
                sendSms(phone, sms);
            }
        }
    }
    private native void sendSms(String phone, String sms);
}

through the JNI Interface, I am able to call sendSms(String phone,String message) defined under

public class DalvikSmsService { ...
private void sendSms(String phone, String message) {
        try {
            String formattedNumber = PhoneNumberUtils.formatNumber(phone);
            Log.i(TAG, "sendSMS phone : " + formattedNumber + ", sms : " + message);
            SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(formattedNumber, null, message, null, null);
        } catch (Exception exc) {
            exc.printStackTrace();
            Log.i(TAG, "sendSMS sending failed, please try again");
        }
    }
}

my AndroidManifest.xml file

    ...
    <uses-permission android:name="android.permission.SEND_SMS"/>
    <application>
        <service android:name="com.gluonhq.helloandroid.DalvikSmsService"
                 android:permission="android.permission.SEND_SMS"
                 android:exported="true"/>
        <activity android:name=".PermissionRequestActivity"/>
      ...

the logs clearly show the method is called (with the phone number edited out)

01-13 08:45:56.760: D/GraalGluon(4546): ATTACH_DALVIK, tid = 4587, existed? 1, dalvikEnv at 0x799ff67ca470
01-13 08:45:56.763: I/DalvikSmsService(4546): sendSMS phone : 256-701-XYZXYZ, sms : Hello JavaFx Message 
01-13 08:45:56.780: D/SmsNumberUtils(936): enter filterDestAddr. destAddr="[dH0eoa3ufMriilJ2cZIb3LD2V7g]"
01-13 08:45:56.782: D/SmsNumberUtils(936): destAddr is not formatted.
01-13 08:45:56.782: D/SmsNumberUtils(936): leave filterDestAddr, new destAddr="[dH0eoa3ufMriilJ2cZIb3LD2V7g]"
01-13 08:45:56.798: D/GraalGluon(4546): DETACH_DALVIK, tid = 4587, existed = 1, env at 0x799ff67ca470

BUT this message is never delivered !!!!. what could I be doing wrongly???

java

android

javafx

gluon

graalvm

0 Answers

Your Answer

Accepted video resources