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
SdlBroadcastReceiver

Class SdlBroadcastReceiver

Hierarchy

java.lang.Object
     android.content.BroadcastReceiver

Package
com.smartdevicelink.transport

Fields

SDL_ROUTER_SERVICE_CLASS_NAME

protected static final java.lang.String SDL_ROUTER_SERVICE_CLASS_NAME
Constant Value
"sdlrouterservice"

ANDROID_12_ROUTER_SERVICE_VERSION

protected static final int ANDROID_12_ROUTER_SERVICE_VERSION
Constant Value
16

LOCAL_ROUTER_SERVICE_EXTRA

public static final java.lang.String LOCAL_ROUTER_SERVICE_EXTRA
Constant Value
"router_service"

LOCAL_ROUTER_SERVICE_DID_START_OWN

public static final java.lang.String LOCAL_ROUTER_SERVICE_DID_START_OWN
Constant Value
"did_start"

TRANSPORT_GLOBAL_PREFS

public static final java.lang.String TRANSPORT_GLOBAL_PREFS
Constant Value
"SdlTransportPrefs"

IS_TRANSPORT_CONNECTED

public static final java.lang.String IS_TRANSPORT_CONNECTED
Constant Value
"isTransportConnected"

runningBluetoothServicePackage

public static java.util.Vector runningBluetoothServicePackage

Constructors

SdlBroadcastReceiver()

public SdlBroadcastReceiver()

Methods

getRouterServiceVersion()

public int getRouterServiceVersion()

onReceive( Context context, Intent intent )

public void onReceive(Context context,Intent intent)

Method Parameters

context
intent

setForegroundExceptionHandler()

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

context
A context to access Android system services through.
packageName
Package name for service to ping
className
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

context

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

e
the exception that occurred

consumeQueuedRouterService()

public static android.content.ComponentName consumeQueuedRouterService()

defineLocalSdlRouterClass()

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

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

getSdlServiceName()

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