To send a message, we will create a POST endpoint that takes a Message object, which we'll then pull apart and pass to Android's telephony APIs.
@POST @Path("conversations") public Response sendMessage(Message message) throws InterruptedException { final SmsManager sms = SmsManager.getDefault(); final ArrayList<String> parts = sms.divideMessage(message.getBody()); final CountDownLatch sentLatch = new CountDownLatch(parts.size()); final AtomicInteger statusCode = new AtomicInteger( Response.Status.CREATED.getStatusCode()); final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (getResultCode() != Activity.RESULT_OK) { statusCode.set( Response.Status.INTERNAL_SERVER_ERROR ...