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
AndroidTools

Class AndroidTools

Hierarchy

java.lang.Object

Package
com.smartdevicelink.util

Constructors

AndroidTools()

public AndroidTools()

Methods

isServiceExported( Context context, ComponentName name )

Check to see if a component is exported

public static boolean isServiceExported(Context context,ComponentName name)

Method Parameters

context
object used to retrieve the package manager
name
of the component in question

getSdlEnabledApps( Context context, String myPackageName )

Get all SDL enabled apps. If the package name is null, it will return all apps. However, if the package name is included, the resulting hash map will not include the app with that package name.

public static java.util.HashMap getSdlEnabledApps(Context context,String myPackageName)

Method Parameters

context
a context object used to get an instance of the package manager
myPackageName
the package of the requesting app. This should only be included if the app wants to exclude itself from the map

querySdlAppInfo( Context context, java.util.Comparator<com.smartdevicelink.util.SdlAppInfo> comparator )

Deprecated
Finds all SDL apps via their SdlRouterService manifest entry. It will return the metadata associated with that router service.

public static java.util.List querySdlAppInfo(Context context,java.util.Comparator<com.smartdevicelink.util.SdlAppInfo> comparator)

Method Parameters

context
a context instance to obtain the package manager
comparator
the Comparator to sort the resulting list. If null is supplied, they will be returned as they are from the system

querySdlAppInfo( Context context, java.util.Comparator<com.smartdevicelink.util.SdlAppInfo> comparator, VehicleType type )

Finds all SDL apps via their SdlRouterService manifest entry. It will return the metadata associated with that router service.

public static java.util.List querySdlAppInfo(Context context,java.util.Comparator<com.smartdevicelink.util.SdlAppInfo> comparator,VehicleType type)

Method Parameters

context
a context instance to obtain the package manager
comparator
the Comparator to sort the resulting list. If null is supplied, they will be returned as they are from the system
type

isPermissionGranted( String permissionName, Context context, String servicePackageName )

public static boolean isPermissionGranted(String permissionName,Context context,String servicePackageName)

Method Parameters

permissionName
context
servicePackageName

sendExplicitBroadcast( Context context, Intent intent, java.util.List<android.content.pm.ResolveInfo> apps )

Sends the provided intent to the specified destinations making it an explicit intent, rather than an implicit intent. A direct replacement of sendBroadcast(Intent). As of Android 8.0 (API 26+) implicit broadcasts are no longer sent to broadcast receivers that are declared via the AndroidManifest. If no apps are found to receive the intent, this method will send the broadcast implicitly if no list of apps is provided.

public static void sendExplicitBroadcast(Context context,Intent intent,java.util.List<android.content.pm.ResolveInfo> apps)

Method Parameters

context
intent
- the intent to send explicitly
apps
- the list of apps that this broadcast will be sent to. If null is passed in the intent will be sent to all apps that match the provided intent via a query to the package manager; it will also be sent implicitly to mimic sendBroadcast()'s original functionality.

isUSBCableConnected( Context context )

Checks if the usb cable is physically connected or not Note: the intent here is a sticky intent so registerReceiver is actually a synchronous call and doesn't register a receiver on each call

public static boolean isUSBCableConnected(Context context)

Method Parameters

context
a context instance

downloadImage( String urlStr )

public static android.graphics.Bitmap downloadImage(String urlStr) throws java.io.IOException

Method Parameters

urlStr

Throws

  • java.io.IOException

isDebugMode( Context context )

public static boolean isDebugMode(Context context)

Method Parameters

context

saveVehicleType( Context context, VehicleType vehicleType, String address )

Saves the mac address along with vehicle details into user's shared prefs.

public static void saveVehicleType(Context context,VehicleType vehicleType,String address)

Method Parameters

context
a context instance to obtain the shared preferences.
vehicleType
a RPCStruct that describes the type of vehicle the mobile phone is connected with.
address
a string containing the Bluetooth Mac address of the connected vehicle.

getVehicleTypeFromPrefs( Context context, String address )

Retrieves the vehicle details by the mac address of the connected vehicle.

public static java.util.Hashtable getVehicleTypeFromPrefs(Context context,String address)

Method Parameters

context
a context instance to obtain the shared preferences.
address
a string containing the Bluetooth Mac address of the connected vehicle.

getVehicleTypesFromManifest( Context context, ComponentName component, int manifestFieldId )

Retrieves the list of vehicle types that are set in the manifest.

public static java.util.List getVehicleTypesFromManifest(Context context,ComponentName component,int manifestFieldId)

Method Parameters

context
a context to access Android system services through.
component
a component name of a LocalRouterService.
manifestFieldId
a string resources id that indicates a unique name for the vehicle data in the manifest.

Inherited Methods

From Class Methods
java.lang.Object getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize
View on GitHub.com
Previous Section Next Section