Showing posts with label SmsManager. Show all posts
Showing posts with label SmsManager. Show all posts

How to Get a Default Instance of SmsManager

public static SmsManager getDefault () was added in API level 4
Get the default instance of the SmsManager
Returns: the default instance of the SmsManager

1. In the MainActivity.java file, Declare a SmsManager object named mySmsManager

2. In the onCreate method, add the below line. This will get the default instance of the SmsManager and save it to a SmsManager object named mySmsManager

mySmsManager = SmsManager.getDefault();

How to Declare a SmsManager object

SmsManager was added in API Level 1
Manages SMS operations such as sending data, text, and pdu SMS messages.

1. In the MainActivity.java file, add the below to the import section.

import android.telephony.SmsManager

2. In the onCreate method, add the below line. This will create a SmsManager object named mySmsManager.

SmsManager mySmsManager;

3. Compile and run!

4. Next, Get a Default Instance of SmsManager

Resources:
Professional Android 4 Application Development by Reto Meier, pg 714
http://developer.android.com/reference/android/telephony/SmsManager.html