public class Util extends Object
Copyright (c) 2011-2014 Bit Stadium GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Modifier and Type | Field and Description |
---|---|
static int |
APP_IDENTIFIER_LENGTH |
static String |
APP_IDENTIFIER_PATTERN |
static String |
LOG_IDENTIFIER |
static String |
PREFS_FEEDBACK_TOKEN |
static String |
PREFS_KEY_FEEDBACK_TOKEN |
static String |
PREFS_KEY_NAME_EMAIL_SUBJECT |
static String |
PREFS_NAME_EMAIL_SUBJECT |
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static boolean |
classExists(String className)
Helper method to safely check whether a class exists at runtime.
|
static android.app.Notification |
createNotification(android.content.Context context,
android.app.PendingIntent pendingIntent,
String title,
String text,
int iconId)
Creates a notification on API levels from 9 to 23
|
static String |
encodeParam(String param)
Returns the given param URL-encoded.
|
static Boolean |
fragmentsSupported()
Returns true if the Fragment API is supported (should be on Android 3.0+).
|
static String |
getFormString(Map<String,String> params)
Converts a map of parameters to a HTML form entity.
|
static boolean |
isConnectedToNetwork(android.content.Context context) |
static boolean |
isNotificationBuilderSupported()
Checks if the Notification.Builder API is supported.
|
static boolean |
isValidEmail(String value)
Returns true if value is a valid email.
|
static Boolean |
runsOnTablet(WeakReference<android.app.Activity> weakActivity)
Returns true if the app runs on large or very large screens (i.e. tablets).
|
static String |
sanitizeAppIdentifier(String appIdentifier)
Sanitizes an app identifier or throws an exception if it can't be sanitized.
|
public static final String PREFS_FEEDBACK_TOKEN
public static final String PREFS_KEY_FEEDBACK_TOKEN
public static final String PREFS_NAME_EMAIL_SUBJECT
public static final String PREFS_KEY_NAME_EMAIL_SUBJECT
public static final String APP_IDENTIFIER_PATTERN
public static final int APP_IDENTIFIER_LENGTH
public static final String LOG_IDENTIFIER
public static String encodeParam(String param)
param
- a string to encodepublic static final boolean isValidEmail(String value)
value
- a stringpublic static Boolean fragmentsSupported()
public static Boolean runsOnTablet(WeakReference<android.app.Activity> weakActivity)
weakActivity
- the context to usepublic static String sanitizeAppIdentifier(String appIdentifier) throws IllegalArgumentException
appIdentifier
- the app identifier to sanitizeIllegalArgumentException
- if the app identifier can't be sanitized because of unrecoverable input character errorspublic static String getFormString(Map<String,String> params) throws UnsupportedEncodingException
params
- the parametersUnsupportedEncodingException
- when your system does not know how to handle the UTF-8 charsetpublic static boolean classExists(String className)
className
- the full-qualified class name to check forpublic static boolean isNotificationBuilderSupported()
public static android.app.Notification createNotification(android.content.Context context, android.app.PendingIntent pendingIntent, String title, String text, int iconId)
context
- the context to use, e.g. your ActivitypendingIntent
- the Intent to calltitle
- the title string for the notificationtext
- the text content for the notificationcrashiconId
- the icon resource ID for the notificationpublic static boolean isConnectedToNetwork(android.content.Context context)
Copyright © 2015. All Rights Reserved.