CodenameOne icon indicating copy to clipboard operation
CodenameOne copied to clipboard

Android device returns SMS_NOT_SUPPORTED incorrectly

Open jnorth515 opened this issue 1 year ago • 3 comments

As requested I am filing an issue regarding the getSMSSupport() method. This refers to this post on stack overflow Stack overflow and this method below getSMSSupport()

Galaxy fold type devices are causing an issue where SMS_NOT_SUPPORTED is returned when calling getSMSSupport(). As Shai explained, since they are both a phone and a tablet this is causing the issue. So even though devices are able to send SMS they return not supported

Below code as an example: -

try {
    switch(Display.getInstance().getSMSSupport()) {
        case Display.SMS_NOT_SUPPORTED:
            errMes = "SMS not supported by this device";
            return false;
        case Display.SMS_SEAMLESS:                    
            Display.getInstance().sendSMS(formatedIntercomTele,Message, false);
            return true;
        case Display.SMS_INTERACTIVE:
            Display.getInstance().sendSMS(formatedIntercomTele,Message, true); 
            return true;
        default:
            Display.getInstance().sendSMS(formatedIntercomTele,Message, true); 
            return true;
    }            
} catch (IOException ex) {
    errMes = "Unable to send message";
    return false;
}         

Simply commenting out the case SMS_NOT_SUPPORTED allows the device to open the default messaging app as expected.

jnorth515 avatar Jul 05 '22 10:07 jnorth515

Is there likely to be any change regarding this issue soon? I can simply leave the SMS_NOT_SUPPORTED check out however I will receive a error log anytime an attempt is made to send a message from an actual tablet. As per below

Exception: android.content.ActivityNotFoundException - No Activity found to handle Intent { act=android.intent.action.SENDTO dat=smsto:xxxxxxxxxxx (has extras) } android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SENDTO dat=smsto:xxxxxxxxxxx (has extras) }

jnorth515 avatar Jul 07 '22 12:07 jnorth515

You can use the device detector cn1lib to explicitly detect the fold and other problematic devices as a workaround.

shai-almog avatar Jul 08 '22 03:07 shai-almog

Ok thank you for the help as always. I've added a warning to the user with the option to remove the warning for future use etc. For now I suppose most cases will not be affected by this

jnorth515 avatar Jul 08 '22 10:07 jnorth515