Your SlideShare is downloading. ×
  • Like
Android telephony api
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply


Published in Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Mr. Pritesh N. Patel Assistant Professor MCA ISTAR. V. V. Nagar
  • 2.  An Android SDK provides number of useful utilities for application to integrate phone feature available on the device. 1. Application may need to know the state of phone call and behave accordingly. 2. Application may need to place a call or want to send a text SMS.
  • 3.  It Provides access to information about the telephony services on the device.  Applications can use the methods in this class to determine telephony services and states, as well as to access some types of subscriber information.  Applications can also register a listener to receive notification of telephony state changes.  The telephony API is used to among other things monitor phone information including the current states of the phone, connections, network etc.  Access to some telephony information is permission-protected. Your application cannot access the protected information unless it has the appropriate permissions declared in its manifest file.
  • 4.  The TelephonyManager object within the android.telephony package is used to handle phone state.  You do not instantiate this class directly; instead, you retrieve a reference to an instance through Context.getSystemService(Context.TELEPHONY_SERVICE) For e.g. TelephonyManager tMger; tMger =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); Permission for Phone Service <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS“/>
  • 5.  Following code snippet is used to call a phone. Write a code on Button click and get phone number from EditText view. Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:9726344355")); startActivity(callIntent);
  • 6. PhoneCallListener phoneListener = new PhoneCallListener(); TelephonyManager telephonyManager = (TelephonyManager) this .getSystemService(Context.TELEPHONY_SER VICE); telephonyManager.listen(phoneListener,Phon eStateListener.LISTEN_CALL_STATE);
  • 7. private class PhoneCallListener extends PhoneStateListener { private boolean isPhoneCalling = false; String LOG_TAG = "LOGGING 123"; @Override public void onCallStateChanged(int state, String incomingNumber) { if (TelephonyManager.CALL_STATE_RINGING == state) { Log.i(LOG_TAG, "RINGING, number: " + incomingNumber); } if (TelephonyManager.CALL_STATE_OFFHOOK == state) { Log (LOG_TAG, "OFFHOOK"); isPhoneCalling = true; } if (TelephonyManager.CALL_STATE_IDLE == state) { Log.i(LOG_TAG, "IDLE"); if (isPhoneCalling) { Log.i(LOG_TAG, "restart app"); Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage( getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); isPhoneCalling = false; } } } }
  • 8. String formatNumber = PhoneNumberUtils.formatNumber(“9726344355”); Output: 972-634-4355
  • 9. private void sendSms(String one,String two) { Intent i=new Intent(this,MainActivity.class); PendingIntent pi=PendingIntent.getActivity(this, 0, i,0); SmsManager sms=SmsManager.getDefault(); sms.sendTextMessage(tNo, null, msg, pi,null); } Permission for SMS Service <uses-permission android:name="android.permission.SEND_SMS"> </uses-permission> <uses-permission android:name="android.permission.RECEIVE_SMS"> </uses-permission>