-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
78 lines (56 loc) · 1.57 KB
/
app.js
File metadata and controls
78 lines (56 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
// criando dois botões para chamada das intents
var b1 = Ti.UI.createButton({
width:'auto',
height: 100,
title:'Enviar SMS',
top:0
});
var b2 = Ti.UI.createButton({
width:'auto',
height: 100,
title:'Enviar SMS diretamente',
top:300
});
b1.addEventListener('click',function(e){
// criando o objeto intent com seus atributos básicos
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
type: 'vnd.android-dir/mms-sms'
});
intent.putExtra('sms_body', 'texto da mensagem');
intent.putExtra('address', '1111111');
// inicializando a atividade
Ti.Android.currentActivity.startActivity(intent);
});
b2.addEventListener('click',function(e){
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SENDTO, // repare que aqui a action é do tipo SENDTO (apenas envio)
data: 'smsto:11111111'
});
intent.putExtra('sms_body', 'texto da mensagem');
Ti.Android.currentActivity.startActivity(intent);
});
win1.add(b1);
win1.add(b2);
//
// add tabs
//
tabGroup.addTab(tab1);
// open tab group
tabGroup.open();