User Tools

Site Tools


install

This is an old revision of the document!


Installing Super Duper SMS Manager

1. Download the SDK

2. In a strings file in /res, add your SDSMS_ID:

<string name="SDSMS_ID">UNREGISTERED_APP</string>

If you have a registration ID, enter it here. Otherwise, this can be anything you want it to be (or leave it alone). Setting it to a unique value is recommended.

3. Determine the appropriate interface type for your app based on these values as indicated here: Access Types

4. Replace SmsManager wtih SDSmsManager anywhere you use it in your project. If you set it globally in an Application class, that will work too. For example replace:

SmsManager mSmsManager = SmsManager.getDefault();

with this:

SDSmsManager mSDSmsManager = SDSmsManager.getDefault(context, context.getString(R.string.SDSMS_ID),
      SDSmsManager.ACCESS_TYPE_MESSAGING);

5. Replace all SmsManager calls with mSDSmsManager, like this:

	SDSmsManager sms = SDSmsManager.getDefault(context, context.getString(R.string.SDSMS_ID),
        		SDSmsManager.ACCESS_TYPE_MESSAGING);
	try {
		sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
	} catch (Exception e) {
		// error sending message, notify user and update database
	    		sendError(msgId, phoneNumber);
	}

6. If you use a SqliteWrapper like many examples provide, simply replace you import statement in those classes with the following:

import com.sirisdevelopment.superdupersmsmanager.database.sqlite.SqliteWrapper;

The included class does URI resolution normally except that the standard “sms” authority is replaced with the “sdsms” authority when SDSMS is the Default Messaging App.

Also included in the SDSMS SqliteWrapper is the SDContentResolver class. This class simply checks to see if you URI should be converted to SDSMS Uri's prior to being resolved. This can be used to Replace the standard ContentResolver class and will resolve “sms” related authorities appropriately. For example, if this is your code:

ContentResolver contentResolver = getContentResolver();
 
final String[] projection = new String[] { "retr_st", "date", "_id", "ct_t" };
Uri uri = Uri.parse("content://mms-sms/conversations");
 
Cursor cursor = contentResolver.query(uri, projection, null, null, "_id DESC");

can be written as this, and the “sms” authority will resolve to “sdsms” when necessary:

SDContentResolver sdContentResolver = new SDContentResolver(context);
 
final String[] projection = new String[] { "retr_st", "date", "_id", "ct_t" };
Uri uri = Uri.parse("content://mms-sms/conversations");
 
Cursor cursor = sdContentResolver.query(uri, projection, null, null,"_id DESC");

This is a convenience method only. We do not require that you use SDContentResolver.

Also, this class will make the appropriate calls to SDSMS to acknowledge your proper integration.

7. In some cases, you may reference Uri's from Telephony or even statically. All MmsSms Uri's need to be determined via methods that are provided. For example to get the Sms.Inbox Uri replace the following:

Sms.Inbox.CONTENT_URI

with this code (and import SDSmsManager into any classes that do not already have it):

SDSmsManager.Sms.Inbox.CONTENT_URI()

As a side note, if you create or make static references to these Uri's, this will not work because the methods will only execute as the app is instantiated. If the user changes the default SMS app, then your app may not behave properly. These must be runtime references. These are static methods, so your compiler will not complain but it will most likely result in problems.

8. Implement the SDSMS callback for received messages. This allows you to tell SDSMS if your app attempted to abort the incoming SMS. Here is an example:

	private ISDSmsReceiveCallback.Stub mCallback = new ISDSmsReceiveCallback.Stub() {
		@Override
		public boolean onReceive(Intent intent) throws RemoteException {
			//
			// do stuff here to process the SMS message
			// in this example, we are trying to demonstrate that you could re-use
			// existing code but return the appropriate result for "abort"
			// 
			// true - abort broadcast
			//
			// false - your app did not abort the broadcast
			//
			SmsIntentReceiver receiver = new SmsIntentReceiver();
			return receiver.onReceive(intent);
		}
 
	};

In this example, the intent is processed and will be passed back to SDSMS unless the callback returns a value of “true” - indicating that your app aborted the SMS broadcast.

install.1393883128.txt.gz · Last modified: 2014/03/03 21:45 by superdupersms