You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developer-guide/Miscellaneous-Features.asciidoc
+28-30Lines changed: 28 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,23 @@ Most of the low level phone functionality is accessible in the https://www.coden
6
6
7
7
==== SMS
8
8
9
-
Codename One supports sending SMS messages but not receiving them as this functionality isn't portable. You can send an SMS using:
9
+
Codename One supports sending SMS messages but not receiving them as this functionality isn't portable. You can send an SMS using either the `Display` singleton or the static helper methods on `CN`. Both APIs throw `IOException`, which you should handle in case the native layer reports a failure:
10
10
11
11
[source,java]
12
12
----
13
-
Display.getInstance().setSMS("+999999999", "My SMS Message");
13
+
try {
14
+
Display.getInstance().sendSMS("+999999999", "My SMS Message");
15
+
// Or: CN.sendSMS("+999999999", "My SMS Message");
16
+
} catch(IOException err) {
17
+
Log.e(err);
18
+
Dialog.show("SMS Failed", "Unable to send the SMS", "OK", null);
19
+
}
14
20
----
15
21
16
-
Android/Blackberry support sending SMS's in the background without showing the user anything. 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. Android supports that capability as well (launching the OS native SMS app).
22
+
Android supports sending SMS messages in the background without any UI. iOS doesn't provide that ability, so the best it can offer is to launch the native SMS app with your message composed for the user to send. Android supports that interactive flow as well (launching the OS native SMS app).
17
23
18
-
The default `sendSMS` API ignores that difference and simply works interactively on iOS/Windows Phone while sending
19
-
in the background for the other platforms.
24
+
The default `sendSMS` API ignores that difference and simply works interactively on iOS while sending
25
+
in the background for Android when the platform allows it.
20
26
21
27
The `getSMSSupport` API returns one of the following options:
22
28
@@ -35,16 +41,21 @@ A typical use of this API would be something like this:
35
41
36
42
[source,java]
37
43
----
38
-
switch(Display.getInstance().getSMSSupport()) {
39
-
case Display.SMS_NOT_SUPPORTED:
40
-
return;
41
-
case Display.SMS_SEAMLESS:
42
-
showUIDialogToEditMessageData();
43
-
Display.getInstance().sendSMS(phone, data);
44
-
return;
45
-
default:
46
-
Display.getInstance().sendSMS(phone, data);
47
-
return;
44
+
try {
45
+
switch(Display.getInstance().getSMSSupport()) {
46
+
case Display.SMS_NOT_SUPPORTED:
47
+
return;
48
+
case Display.SMS_SEAMLESS:
49
+
showUIDialogToEditMessageData();
50
+
Display.getInstance().sendSMS(phone, data);
51
+
return;
52
+
default:
53
+
Display.getInstance().sendSMS(phone, data);
54
+
return;
55
+
}
56
+
} catch(IOException err) {
57
+
Log.e(err);
58
+
Dialog.show("SMS Failed", "Unable to send the SMS", "OK", null);
48
59
}
49
60
----
50
61
@@ -85,19 +96,6 @@ Display.getInstance().sendMessage(new String[] {"[email protected]"}, "Subject o
85
96
86
97
NOTE: Some features such as attachments etc. don't work correctly in the simulator but should work on iOS/Android
87
98
88
-
The email messaging API has an additional ability within the https://www.codenameone.com/javadoc/com/codename1/messaging/Message.html[Message] class. The `sendMessageViaCloud`
89
-
method allows you to use the Codename One cloud to send an email without end user interaction. This feature is available to pro users only since it makes use of the Codename One cloud:
90
-
91
-
[source,java]
92
-
----
93
-
Message m = new Message("<html><body>Check out <a href=\"https://www.codenameone.com/\">Codename One</a></body></html>");
94
-
m.setMimeType(Message.MIME_HTML);
95
-
96
-
// notice that we provide a plain text alternative as well in the send method
"Check out Codename One at https://www.codenameone.com/");
99
-
----
100
-
101
99
=== Contacts API
102
100
103
101
The contacts API provides us with the means to query the phone’s address book, delete elements from it and create new entries into it. To get the platform specific list of contacts you can use
@@ -118,7 +116,7 @@ Here you can specify true only for the attributes that actually matter to you.
118
116
119
117
Another capability of the contacts API is the ability to extract all of the contacts very quickly. This isn't supported on all platforms but platforms such as Android can really get a boost from this API as extracting the contacts one by one is remarkably slow on Android.
120
118
121
-
You can check if a platform supports the extraction of all the contacts quickly thru `ContactsManager.isGetAllContactsFast()`.
119
+
You can check if a platform supports the extraction of all the contacts quickly thru `ContactsManager.isAllContactsFast()`.
122
120
123
121
IMPORTANT: When retrieving all the contacts, notice that you should probably not retrieve all the data and should set some fields to false to perform a more efficient query
124
122
@@ -129,7 +127,7 @@ You can then extract all the contacts using code that looks a bit like this, not
129
127
Form hi = new Form("Contacts", new BoxLayout(BoxLayout.Y_AXIS));
0 commit comments