16
Telephony API Ramin Orujov 22.04.2012

Telephony API

Embed Size (px)

DESCRIPTION

Telephony APIRamin Orujov

Citation preview

Page 1: Telephony API

Telephony APIRamin Orujov

22.04.2012

Page 2: Telephony API

Agenda

• API overview• Working with SMS• Working with phone calls• Working with MMS

Page 4: Telephony API

SMS

Permissions:• android.permission.SEND_SMS• android.permission.RECEIVE_SMSMain classes: • SmsManager• SmsMessage

Page 5: Telephony API

SMS

How to send sms• Get SmsManager instanceSmsManager m = SmsManager.getDefault();• Send text smsvoid sendTextMessage (String

destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntentdeliveryIntent)

Page 6: Telephony API

SMS

How to read incoming smsExtends BroadcastReceiver and listen for actionandroid.provider.Telephony.SMS_RECEIVED

How to get sent and delivery reportPendingIntent for both actions

Page 7: Telephony API

SMS

• API docshttp://developer.android.com/reference/android/telephony/SmsManager.html

Page 8: Telephony API

Phone call

• Call number• Detect incoming and outgoing calls• Listen phone state changes

Page 9: Telephony API

Phone call

How to call numberIntent intent = new Intent(Intent.ACTION_CALL,

Uri.parse("tel:502310109")); startActivity(intent);

Permission:• android.permission.CALL_PHONE

Page 10: Telephony API

Phone call

How to detect incoming and outgoing calls• Extend BroadcastReceiver and listen for action android.intent.action.PHONE_STATEandroid.intent.action.NEW_OUTGOING_CALL

Page 11: Telephony API

Phone call

• How to get phone state change eventsPermissions• android.permission.READ_PHONE_STATE• android.permission.ACCESS_COARSE_LOCATION• android.permission.ACCESS_NETWORK_STATE• android.permission.ACCESS_COARSE_UPDATES

Page 12: Telephony API

Phone call

• API docshttp://developer.android.com/reference/android/telephony/TelephonyManager.html

Page 13: Telephony API

MMS

Uri mmsUri = Uri.parse("content://media/external/images/media/1");

Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra("sms_body", “This is a test mms ");intent.putExtra(Intent.EXTRA_STREAM, mmsUri); intent.setType("image/png"); startActivity(intent);

Page 15: Telephony API

Questions?

Page 16: Telephony API

Contact me

http://raminorucov.wordpress.comhttp://www.facebook.com/ramin.orucovhttp://www.linkedin.com/in/raminorujov http://twitter.com/RaminOrujov