Telephony API

Preview:

DESCRIPTION

Telephony APIRamin Orujov

Citation preview

Telephony APIRamin Orujov

22.04.2012

Agenda

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

SMS

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

SMS

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

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

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

SMS

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

Phone call

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

Phone call

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

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

Permission:• android.permission.CALL_PHONE

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

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

Phone call

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

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);

Questions?

Contact me

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

Recommended