www hndit com HNDIT 2417 Mobile Application Development
www. hndit. com HNDIT 2417 Mobile Application Development Week 7 - SMS
www. hndit. com SMS
www. hndit. com SMS • In Android, you can use – Sms. Manager API or – devices Built-in SMS application to send SMS's.
Sms. Manager API • • www. hndit. com Sms. Manager sms. Manager = Sms. Manager. get. Default(); sms. Manager. send. Text. Message("phone. No", null, "sms message", null); • Syntax and Parameters of send. Text. Message is: • public final void send. Text. Message ( String destination. Address, String sc. Address, String text, Pending. Intent sent. Intent, Pending. Intent delivery. Intent)
www. hndit. com Parameters destination. Address sc. Address the address to send the message to is the service center address or null to use the current default SMSC text sent. Intent the body of the message to send if not NULL this Pending. Intent is broadcast when the message is successfully sent, or failed. The result code will be. Activity. RESULT_OK for success, or one of these errors: RESULT_ERROR_GENERIC_FAILURERESULT_ERROR_RADIO_ OFF RESULT_ERROR_NULL_PDU. The per-application based SMS control checks sent. Intent. If sent. Intent is NULL the caller will be checked against all unknown applications, which cause smaller number of SMS to be sent in checking period. delivery. Intent if not NULL this Pending. Intent is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").
Built-in SMS application www. hndit. com • Intent send. Intent = new Intent(Intent. ACTION_VIEW); • send. Intent. put. Extra("sms_body", "default content"); • send. Intent. set. Type("vnd. android-dir/mms-sms"); • start. Activity(send. Intent);
www. hndit. com SEND_SMS permission. • In order to send SMS permission should be specified in the Android. Manifest. xml <uses-permission android: name="android. permission. SEND_SMS" />
- Slides: 7