Class Overview
This class provides APIs to customize device font.
Summary
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public Methods
public
String
getSystemActiveFont
()
API to get the current font set on the device.
Returns
- Current active font on device if successful, else
null
Usage
An administrator can use this API to retrieve the currently active device font. |
public
float
getSystemActiveFontSize
()
API to get the font size currently set on the device.
Returns
- Current active font size on device if successful, else 0.0
Usage
An administrator can use this API to retrieve the size of the current active device font. |
public
float[]
getSystemFontSizes
()
API to get the supported font sizes on the device.
Returns
- Supported font sizes on device if successful, else
null
Usage
An administrator can use this API to retrieve the supported font sizes from the
device.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
Font font = edm.getFont();
// get all font sizes from device
float[] sysFontSizes = font.getSystemFontSizes();
for (int i = 0; i < sysFontSizes.length; i++) {
Log.d(TAG, "Available font sizes :" + sysFontSizes[i]);
}
|
public
String[]
getSystemFonts
()
API to get all available fonts on the device.
Returns
- All available fonts on device if successful, else
null
Usage
An administrator can use this API to retrieve all available fonts from the device.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
Font font = edm.getFont();
//get all fonts from device
String[] sysFonts = font.getSystemFonts();
for(int i=0; i < sysFonts.length; i++){
Log.d(TAG, " System available fonts :"+sysFonts[i]);
}
//OUTPUT:"Arial","verdina"
|
public
boolean
setSystemActiveFont
(String fontName, String apkPath)
API to set the device font.
Parameters
fontName
| Name of the file that has new font data |
apkPath
| path of the file that has new font data. This path is needed only if
the administrator want to set a font to be the active font that is not available in the device.
From Android 4.2, pass "null " as custom font is not supported. |
Returns
true
if operation is successful, else false
Usage
An administrator can use this API to change device's font. This setting
overrides the current font.
Note: The font set by this API gets erased after a factory reset, and the original
default font becomes the currently active font.
Form Android version 4.2 onwards, this API will not support font apk installation.
Administrator needs to pass "null " for apk path otherwise call will return failure.
Only preloaded fonts in device can be set and administrator can use
getSystemFonts() to get font name and pass that value for fontname.
//sample code to change device font from existing list of device fonts
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
Font font = edm.getFont();
try {
//get Active font
String activeFont = font.getSystemActiveFont();
//get all fonts from device
String[] sysFonts = font.getSystemFonts();
for (i=0; i < sysFonts.length; i++){
Log.d(TAG," SystemFont: " + sysFonts[i] );
if (!activeFont.equalsIgnoreCase(sysFonts[i])){
Log.d(TAG," set as active font " + sysFonts[i] );
break;
}
}
boolean result = font.setSystemActiveFont(sysFonts[i], null);
if(result == true){
Log.d(TAG, "setSystemActiveFont has succeeded!");
}else {
Log.d(TAG, "setSystemActiveFont has failed.");
}
}catch(SecurityException e) {
Log.w(TAG,"SecurityException: "+e);
}
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_SECURITY" permission which has a protection
level of signature. |
public
boolean
setSystemActiveFontSize
(float fontSize)
API to set the device font size.
Parameters
fontSize
| Device font size to be set |
Returns
true
if operation is successful, else false
Usage
An administrator can use this API to change the device's font size. This new font size
overrides the currently active font size.
Note: The font size set by this API is erased after a factory
reset, and the original default font size becomes the active font size.
Supported font sizes on Android 4.0 device:
- Tiny -> 0.85
- Small -> 0.93
- Normal -> 1.0
- Large -> 1.30
- Huge -> 1.80 (Only for specific applications. Large font size
is applied in all other applications)
If an administrator attempts to set the font size to any other value than the system-supported font
sizes, the device font size is set to the closest supported font size.
// sample code to change device font size
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
Font font = edm.getFont();
try {
// administrator can check system-supported font sizes with
// getSystemFontSizes() before setting new font size.
float activeFontSize = 1.0;
boolean result = font.setSystemActiveFontSize(activeFontSize);
if (result == true) {
Log.d(TAG, "setSystemActiveFontSize() success !!!");
} else {
Log.d(TAG, "setSystemActiveFontSize() failure !!!");
}
} catch (SecurityException e) {
Log.w(TAG, "SecurityException: " + e);
}
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_SECURITY" permission which has a
protection level of signature. |