Skip to content

Instantly share code, notes, and snippets.

@omorandi
Created June 7, 2011 21:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save omorandi/1013226 to your computer and use it in GitHub Desktop.
Save omorandi/1013226 to your computer and use it in GitHub Desktop.
Two methods for sending SMS messages with Titanium Mobile on Android throught native intents
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
layout: 'vertical'
});
var bt1 = Ti.UI.createButton({title: 'send message (method 1)', top: 200});
bt1.addEventListener('click', function(e)
{
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SENDTO,
data: 'smsto:123456789'
});
intent.putExtra('sms_body', 'new message from me');
Ti.Android.currentActivity.startActivity(intent);
});
win1.add(bt1);
var bt2 = Ti.UI.createButton({title: 'send message (method 2)'});
bt2.addEventListener('click', function(e)
{
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
type: 'vnd.android-dir/mms-sms'
});
intent.putExtra('sms_body', 'new message from me');
intent.putExtra('address', '123456789');
Ti.Android.currentActivity.startActivity(intent);
});
win1.add(bt2);
win1.open();
@cheloperel
Copy link

Hey! How can you get the status? I need to know if the message was sent or not, is it possible? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment