Fork us on GitHub

SMS & Custom Commands

One of the problems in cross platform development is availabi...

SMS & Custom Commands

One of the problems in cross platform development is availability of functionality on one platform that is missing on another. Case in point sending an SMS message.
Android, Blackberry & J2ME support sending SMS's in the background without showing the user anything. They even support a form of intercepting incoming SMS's to one degree or another (but that's rather problematic).
iOS & Windows Phone just don't have that ability, the best they can offer is to launch the native SMS app with your message already in that app.

Unfortunately our sendSMS API ignored that difference and simply worked interactively on iOS/Windows Phone while sending in the background for the other platforms.

In the next update we will add the API getSMSSupport which will return one of the following options:
  • SMS_NOT_SUPPORTED - for desktop, tablet etc.
  • SMS_SEAMLESS - sendSMS will not show a UI and will just send in the background
  • SMS_INTERACTIVE - sendSMS will show an SMS sending UI
  • SMS_BOTH - sendSMS can support both seamless and interactive mode, this currently only works on Android
And we updated the sendSMS method to: sendSMS(String phoneNumber, String message, boolean interactive)

The last argument will be ignored unless SMS_BOTH is returned from getSMSSupport at which point you would be able to choose one way or the other. The default behavior (when not using that flag) is the background sending which is the current behavior on Android.

Customizing Commands In Runtime
Commands are abstracted so we can integrate deeply into the native platform. E.g. the default behavior on Android is to add commands to the action bar which is what we would assume in the case of Android.
If commands are drawn by us and not native (e.g. if you use the side menu bar or running on iOS etc.) you can easily customize the style of the commands using the "TouchCommand" and "Command" UIID's. However, what happens when you want one command to have a different style (e.g. for a delete command). There are many ways to solve this especially with the SideMenuBar where you can use a custom component or quite a few other features. However, none of them are trivial.

To solve that we added the ability to assign a UIID to a command which will be applied to the element if applicable, just use:
form.getMenuBar().setCommandUIID(cmd, "MyUIID");

This will work in runtime and should implicitly refresh the UI.

Notice: This post was automatically converted using a script from an older blogging system. Some elements might not have come out as intended.... If that is the case please let us know via the comments section below.

Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.