Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Forked from omorandi/gist:1013226
Created June 10, 2011 05:04
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tzmartin/1018258 to your computer and use it in GitHub Desktop.
Save tzmartin/1018258 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();
@deckameron
Copy link

tzmartin,
thank you for your code!
Do you know a way to send SMS without user interaction?
My best,
Douglas

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