public class Util
extends java.lang.Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static void |
announceForAccessibility(android.view.View view,
java.lang.CharSequence text) |
static java.lang.String |
bytesToHex(byte[] bytes)
Helper method to convert a byte array to the hex string.
|
static void |
cancelNotification(android.content.Context context,
int id) |
static boolean |
classExists(java.lang.String className)
Helper method to safely check whether a class exists at runtime.
|
static java.lang.String |
convertAppIdentifierToGuid(java.lang.String appIdentifier)
Sanitizes an app identifier and adds dashes to it so that it conforms to the instrumentation
key format of Application Insights.
|
static java.lang.String |
convertStreamToString(java.io.InputStream inputStream) |
static android.app.Notification |
createNotification(android.content.Context context,
android.app.PendingIntent pendingIntent,
java.lang.String title,
java.lang.String text,
int iconId,
java.lang.String channelId)
Creates a notification on API levels from 9 to 23
|
static java.lang.String |
dateToISO8601(java.util.Date date)
Convert a date object to an ISO 8601 formatted string
|
static java.lang.String |
encodeParam(java.lang.String param)
Returns the given param URL-encoded.
|
static java.lang.String |
getAppIdentifier(android.content.Context context)
Retrieve the HockeyApp AppIdentifier from the Manifest
|
static java.lang.String |
getAppName(android.content.Context context) |
static java.lang.String |
getAppSecret(android.content.Context context)
Retrieve the HockeyApp appSecret from the Manifest
|
static java.lang.String |
getFormString(java.util.Map<java.lang.String,java.lang.String> params)
Converts a map of parameters to a HTML form entity.
|
static java.lang.String |
getManifestString(android.content.Context context,
java.lang.String key) |
static byte[] |
hash(byte[] bytes,
java.lang.String algorithm) |
static boolean |
isConnectedToNetwork(android.content.Context context) |
static boolean |
isDebuggerConnected()
Determines if a debugger is currently attached.
|
static boolean |
isEmulator()
Determines whether the app is running on aan emulator or on a real device.
|
static boolean |
isValidEmail(java.lang.String value)
Returns true if value is a valid email.
|
static java.lang.Boolean |
runsOnTablet(android.content.Context context)
Returns true if the app runs on large or very large screens (i.e.
|
static java.lang.String |
sanitizeAppIdentifier(java.lang.String appIdentifier)
Sanitizes an app identifier or throws an exception if it can't be sanitized.
|
static void |
sendNotification(android.content.Context context,
int id,
android.app.Notification notification,
java.lang.String channelId,
java.lang.CharSequence channelName) |
public static java.lang.String encodeParam(java.lang.String param)
param
- a string to encodepublic static boolean isValidEmail(java.lang.String value)
value
- a stringpublic static java.lang.Boolean runsOnTablet(android.content.Context context)
context
- the context to usepublic static java.lang.String sanitizeAppIdentifier(java.lang.String appIdentifier) throws java.lang.IllegalArgumentException
appIdentifier
- the app identifier to sanitizejava.lang.IllegalArgumentException
- if the app identifier can't be sanitized because of unrecoverable input character errorspublic static java.lang.String getFormString(java.util.Map<java.lang.String,java.lang.String> params) throws java.io.UnsupportedEncodingException
params
- the parametersjava.io.UnsupportedEncodingException
- when your system does not know how to handle the UTF-8 charsetpublic static boolean classExists(java.lang.String className)
className
- the full-qualified class name to check forpublic static android.app.Notification createNotification(android.content.Context context, android.app.PendingIntent pendingIntent, java.lang.String title, java.lang.String text, int iconId, java.lang.String channelId)
context
- the context to use, e.g. your ActivitypendingIntent
- the Intent to calltitle
- the title string for the notificationtext
- the text content for the notificationiconId
- the icon resource ID for the notificationpublic static void sendNotification(android.content.Context context, int id, android.app.Notification notification, java.lang.String channelId, java.lang.CharSequence channelName)
public static void cancelNotification(android.content.Context context, int id)
public static void announceForAccessibility(android.view.View view, java.lang.CharSequence text)
public static java.lang.String getAppIdentifier(android.content.Context context)
context
- usually your Activitypublic static java.lang.String getAppSecret(android.content.Context context)
context
- usually your Activitypublic static java.lang.String getManifestString(android.content.Context context, java.lang.String key)
public static boolean isConnectedToNetwork(android.content.Context context)
public static java.lang.String getAppName(android.content.Context context)
public static java.lang.String convertAppIdentifierToGuid(java.lang.String appIdentifier) throws java.lang.IllegalArgumentException
appIdentifier
- the app identifier to sanitize and convertjava.lang.IllegalArgumentException
- if the app identifier can't be converted because
of unrecoverable input character errorspublic static boolean isEmulator()
public static java.lang.String dateToISO8601(java.util.Date date)
date
- the date object to be formattedpublic static boolean isDebuggerConnected()
public static java.lang.String convertStreamToString(java.io.InputStream inputStream)
public static byte[] hash(byte[] bytes, java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
public static java.lang.String bytesToHex(byte[] bytes)
bytes
- a byte array