FileDocCategorySizeDatePackage
SmsReceiver.javaAPI DocAndroid 1.5 API3564Wed May 06 22:42:46 BST 2009com.android.mms.transaction

SmsReceiver

public class SmsReceiver extends android.content.BroadcastReceiver
Handle incoming SMSes. Just dispatches the work off to a Service.

Fields Summary
static final Object
mStartingServiceSync
static PowerManager.WakeLock
mStartingService
Constructors Summary
Methods Summary
public static voidbeginStartingService(android.content.Context context, android.content.Intent intent)
Start the service to process the current event notifications, acquiring the wake lock before returning to ensure that the service will run.

        synchronized (mStartingServiceSync) {
            if (mStartingService == null) {
                PowerManager pm =
                    (PowerManager)context.getSystemService(Context.POWER_SERVICE);
                mStartingService = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
                        "StartingAlertService");
                mStartingService.setReferenceCounted(false);
            }
            mStartingService.acquire();
            context.startService(intent);
        }
    
public static voidfinishStartingService(android.app.Service service, int startId)
Called back by the service when it has finished processing notifications, releasing the wake lock if the service is now stopping.

        synchronized (mStartingServiceSync) {
            if (mStartingService != null) {
                if (service.stopSelfResult(startId)) {
                    mStartingService.release();
                }
            }
        }
    
public voidonReceive(android.content.Context context, android.content.Intent intent)


    
          
        onReceiveWithPrivilege(context, intent, false);
    
protected voidonReceiveWithPrivilege(android.content.Context context, android.content.Intent intent, boolean privileged)

        // If 'privileged' is false, it means that the intent was delivered to the base
        // no-permissions receiver class.  If we get an SMS_RECEIVED message that way, it
        // means someone has tried to spoof the message by delivering it outside the normal
        // permission-checked route, so we just ignore it.
        if (!privileged && intent.getAction().equals(Intents.SMS_RECEIVED_ACTION)) {
            return;
        }

        intent.setClass(context, SmsReceiverService.class);
        intent.putExtra("result", getResultCode());
        beginStartingService(context, intent);