public class AndroidTools extends Object
| Constructor and Description |
|---|
AndroidTools() |
| Modifier and Type | Method and Description |
|---|---|
static Bitmap |
downloadImage(String urlStr) |
static HashMap<String,ResolveInfo> |
getSdlEnabledApps(Context context,
String myPackageName)
Get all SDL enabled apps.
|
static Hashtable<String,Object> |
getVehicleTypeFromPrefs(Context context,
String address)
Retrieves the vehicle details by the mac address of the connected vehicle.
|
static List<VehicleType> |
getVehicleTypesFromManifest(Context context,
ComponentName component,
int manifestFieldId)
Retrieves the list of vehicle types that are set in the manifest.
|
static boolean |
isDebugMode(Context context) |
static boolean |
isServiceExported(Context context,
ComponentName name)
Check to see if a component is exported
|
static boolean |
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
|
static List<SdlAppInfo> |
querySdlAppInfo(Context context,
Comparator<SdlAppInfo> comparator)
Deprecated.
|
static List<SdlAppInfo> |
querySdlAppInfo(Context context,
Comparator<SdlAppInfo> comparator,
VehicleType type)
Finds all SDL apps via their SdlRouterService manifest entry.
|
static void |
saveVehicleType(Context context,
VehicleType vehicleType,
String address)
Saves the mac address along with vehicle details into user's shared prefs.
|
static void |
sendExplicitBroadcast(Context context,
Intent intent,
List<ResolveInfo> apps)
Sends the provided intent to the specified destinations making it an explicit intent, rather
than an implicit intent.
|
public static boolean isServiceExported(Context context, ComponentName name)
context - object used to retrieve the package managername - of the component in questionpublic static HashMap<String,ResolveInfo> getSdlEnabledApps(Context context, String myPackageName)
context - a context object used to get an instance of the package managermyPackageName - the package of the requesting app. This should only be included if the app wants to exclude itself from the map@Deprecated public static List<SdlAppInfo> querySdlAppInfo(Context context, Comparator<SdlAppInfo> comparator)
context - a context instance to obtain the package managercomparator - the Comparator to sort the resulting list. If null is supplied, they will be returned as they are from the systempublic static List<SdlAppInfo> querySdlAppInfo(Context context, Comparator<SdlAppInfo> comparator, VehicleType type)
context - a context instance to obtain the package managercomparator - the Comparator to sort the resulting list. If null is supplied, they will be returned as they are from the systempublic static void sendExplicitBroadcast(Context context, Intent intent, List<ResolveInfo> apps)
intent - - the intent to send explicitlyapps - - 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.public static boolean isUSBCableConnected(Context context)
context - a context instancepublic static Bitmap downloadImage(String urlStr) throws IOException
IOExceptionpublic static boolean isDebugMode(Context context)
public static void saveVehicleType(Context context, VehicleType vehicleType, String address)
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.@Nullable public static Hashtable<String,Object> getVehicleTypeFromPrefs(Context context, String address)
context - a context instance to obtain the shared preferences.address - a string containing the Bluetooth Mac address of the connected vehicle.@Nullable public static List<VehicleType> getVehicleTypesFromManifest(Context context, ComponentName component, int manifestFieldId)
context - a context to access Android system services through.component - a component name of a LocalRouterService.manifestFieldId - a string resources id that indicates an unique name for the vehicle data in the manifest.