Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
Android Documentation

Class SdlBroadcastReceiver






protected static final java.lang.String SDL_ROUTER_SERVICE_CLASS_NAME
Constant Value


protected static final int ANDROID_12_ROUTER_SERVICE_VERSION
Constant Value


public static final java.lang.String LOCAL_ROUTER_SERVICE_EXTRA
Constant Value


public static final java.lang.String LOCAL_ROUTER_SERVICE_DID_START_OWN
Constant Value


public static final java.lang.String TRANSPORT_GLOBAL_PREFS
Constant Value


public static final java.lang.String IS_TRANSPORT_CONNECTED
Constant Value


public static java.util.Vector runningBluetoothServicePackage



public SdlBroadcastReceiver()



public int getRouterServiceVersion()

onReceive( Context context, Intent intent )

public void onReceive(Context context,Intent intent)

Method Parameters



This method will set a new UncaughtExceptionHandler for the current thread. There are two exceptions we want to catch here. The first exception is the rare occurrence that the SdlRouterService can't be started fast enough by the system after calling startForegroundService so the onCreate method doesn't get called before the foreground promise timer expires. The second is for the instance where the developers "SdlService" class can't be started fast enough by the system after calling startForegroundService OR the app is unable to start the "SdlService" class because the developer did not export the service in the manifest. The new UncaughtExceptionHandler will catch these specific exception and tell the main looper to continue forward. This still leaves the respective Service killed, but prevents an ANR to the app that makes the startForegroundService call.

protected static void setForegroundExceptionHandler()

pingRouterService( Context context, String packageName, String className )

Attempts to ping a running router service. It does call startForegroundService so it is important to only call this as a ping if the service is already started.

protected static void pingRouterService(Context context,String packageName,String className)

Method Parameters

A context to access Android system services through.
Package name for service to ping
Class name for service to ping

queryForConnectedService( Context context )

This call will reach out to all SDL related router services to check if they're connected. If a the router service is connected, it will react by pinging all clients. This receiver will then receive that ping and if the router service is trusted, the onSdlEnabled method will be called.

public static void queryForConnectedService(Context context)

Method Parameters


handleStartServiceException( Exception e )

Convenience method to log details on the specific exception that occurred while attempting to start a foreground service.

protected static void handleStartServiceException(Exception e)

Method Parameters

the exception that occurred


public static android.content.ComponentName consumeQueuedRouterService()


We need to define this for local copy of the Sdl Router Service class. It will be the main point of connection for Sdl enabled apps

public abstract java.lang.Class defineLocalSdlRouterClass()

onSdlEnabled( Context context, Intent intent )

The developer will need to define exactly what should happen when Sdl is enabled. This method will only get called when a Sdl session is initiated.

The most useful code here would be to start the activity or service that handles most of the Livio Connect code.

public abstract void onSdlEnabled(Context context,Intent intent)

Method Parameters

this is the context that was passed to this receiver when it was called.
this is the intent that alerted this broadcast. Make sure to pass all extra it came with to your service/activity {@inheritDoc}


The developer can override this method to return the name of the class that manages their SdlService. This method is used to ensure the SdlBroadcastReceivers exception catcher catches the correct exception that may be thrown by the app trying to start their SdlService. If this exception is not caught the user may experience an ANR for that app.

public java.lang.String getSdlServiceName()

Inherited Methods

From Class Methods
android.content.BroadcastReceiver onReceive, goAsync, peekService, setResultCode, getResultCode, setResultData, getResultData, setResultExtras, getResultExtras, setResult, getAbortBroadcast, abortBroadcast, clearAbortBroadcast, isOrderedBroadcast, isInitialStickyBroadcast, setOrderedHint, setDebugUnregister, getDebugUnregister
java.lang.Object getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize
View on GitHub.com
Previous Section Next Section