Class EDTLibrary
public class EDTLibrary extends Object
This Class holds all static methods required for a Developer to easily access methods and properties of the device where system access rights are required.
- Since:
- 1.00
- API Note:
- The EDT Library is bound to the calling application on application startup time automatically.
The Library's lifecycle therefore depends on the application lifecycle.
Due to the Lifecycle of Android Applications and the underlying timing, it is strongly advised not to call any Library Methods inside theonCreate
method.
When the activity is being launched (and hence the process gets created), the same applies to theonStart
andonResume
methods.
If you need to call any Library methods at application start in one of the above mentioned methods, you should use theCallback
Mechanism offered by theonLibraryReady
method instead.
For instance, instead of callingEDTLibrary.reboot()
directly inonCreate
, use this code to postpone it to aCallback
appropriately:
ScannerLibrary.onLibraryReady(new LibraryCallback() { public void onLibraryReady() { EDTLibrary.reboot(); } });
Which can be simplified to:
EDTLibrary.onLibraryReady(() -> { EDTLibrary.reboot(); });
Or even further to:
EDTLibrary.onLibraryReady(EDTLibrary::reboot);
-
Method Summary
Modifier and Type Method Description static boolean
addNetwork(WifiConfiguration wifiConfiguration)
Add a new network description to the set of configured networks.static boolean
allowUnknownSources(boolean allow)
Specifies whether applications from "unknown sources" (not from Google Play) can be installed on the devicestatic boolean
clearCacheForPackage(String packageName)
Clears the Cache of an Application given by it's package name.static boolean
clearClipboard()
Clears the device's Clipboardstatic boolean
clearDataForPackage(String packageName)
Clears the Data of an Application given by it's package name.static boolean
clearPassword()
Clears the device password (PIN)static boolean
connectNetwork(String ssid)
Connects to an existing network according to it'sSSID
.static boolean
connectNetworkId(int networkId)
Connects to an existing network according to it'snetworkId
.static Path
copyFile(Path sourceFilePath, Path destinationFilePath, CopyOption... options)
Copies a file from one location to another, with a variable number ofStandardCopyOptions
and/orLinkOptions
appliedstatic boolean
createNewApn(APN apn, boolean setAsDefault)
Creates a new Access Point Name (APN) configuration for a carrier data connection and optionally sets it as the new default configuration.static boolean
deleteFile(String filePath)
Removes the specified filestatic boolean
enableAdb(boolean enable)
Enable / disables the ADB connectivity via USBstatic boolean
enableApplication(String packageName, boolean enable)
Enables / Disables a System Application given by it's package name.static boolean
enableBackgroundData(boolean enable)
Specifies whether or not Background Data use is permittedstatic boolean
enableBatteryOptimization(String packageName, boolean enable)
Enables / Disables a Battery Optimization ("Doze Mode") for an Application given by it's package name.
This adds/removes the given application to/from the system's whitelist of Apps which are not subject of battery optimization.static boolean
enableBluetooth(boolean enabled)
Enables/Disables Bluetooth on demandstatic boolean
enableCameras(boolean enable)
Specifies whether or not the Device Cameras can be usedstatic boolean
enableClipboard(boolean enable)
Enable / disables the Clipboardstatic boolean
enableDeveloperMode(boolean enabled)
Enables/Disables Developer Mode on demandstatic boolean
enableDeviceAdmin(String packageName, String className, boolean makeAdmin)
Enables/Disables Device Admin Mode for specific apps/packages on demandstatic boolean
enableGps(boolean enabled)
Enables/Disables GPS on demandstatic boolean
enableMassStorage(boolean enable)
Enable / disables the "USB Mass Storage" aka "File Transfer" modestatic boolean
enableNfc(boolean enabled)
Enables/Disables NFC on demandstatic boolean
enableRoaming(boolean enable)
Specifies whether or not Data Roaming is availablestatic boolean
enableWifi(boolean enabled)
Enables/Disables Wifi on demandstatic boolean
enableWwan(boolean enabled)
Enables/Disables WWAN (3G/LTE/...) on demandstatic boolean
factoryReset(boolean removeAccounts)
Performs a factory reset of the devicestatic APN[]
getAllApnList()
Gets theArray
of existingAccess Point Name (APN)
configurations.static APN
getApn(String name)
Gets theAccess Point Name (APN) configuration
for a carrier data connection by it'sname
.static int
getApnId(String name)
Gets theid
field of an existing Access Point Name (APN) configuration for a carrier data connection.static boolean
getCurrentAndSetNewScanSettings(String settingsFilePath)
Reads current Barcode Scanner settings and applies new Barcode Scanner settings to/from files according to the specified file pathstatic boolean
getCurrentScanSettings(String settingsFilePath)
Write current Barcode Scanner Settings to filestatic Account[]
getGoogleAccounts()
static List<String>
getKeyboardNames()
static boolean
initializeKeyStore(String storeName, String password)
Initialize the given CertificateKeyStore
with the given Password.static boolean
installApk(String apkFilename, boolean update)
Installs an app by it's apk file name.static boolean
installCertificate(String friendlyName, String fileName)
Installs a Certificate from a File.static boolean
isMethodSupported(String methodName)
static boolean
isMethodSupported(BigInteger method)
Check whether theMethod
indicated by theBigInteger
method parameter is supported on the currently active devicestatic boolean
lockDevice()
Locks the Device (i.e. device needs to be unlocked to be used further on)static boolean
mountSDCard(boolean mount)
Mounts/Unmounts the external SD Cardstatic Path
moveFile(Path sourceFilePath, Path destinationFilePath, CopyOption... options)
Moves a file from one location to another, with a variable number ofStandardCopyOptions
appliedstatic void
onLibraryReady(LibraryCallback callback)
Add a new Callback to the Queue of Callbacks to be processed once the EDT Service becomes availablestatic boolean
readFile(ReadWriteFileParams readWriteFileParams)
Reads Data from a Filestatic boolean
reboot()
Performs a device rebootstatic boolean
recovery()
Performs a device reboot into recovery modestatic boolean
rememberPasswords(boolean enable)
Specifies whether or not the Browser may remember Login Passwordsstatic boolean
removeAccount(Account account)
Removes (attempts to remove) a certain account from the devicestatic boolean
removeAllAccounts()
Removes (attempts to remove) all configured accounts of all kind from the devicestatic boolean
removeAllGoogleAccounts()
Removes (attempts to remove) all configured Google accounts from the devicestatic boolean
removeNetwork(String ssid)
Removes an existing network according to it'sSSID
.static boolean
removeNetworkId(int networkId)
Removes an existing network according to it'snetworkId
.static boolean
resetPassword(String newPassword)
Resets the device password (PIN) to a new valuestatic boolean
saveFormData(boolean enable)
Specifies whether or not the Browser may save Form Input Datastatic boolean
setDateTime(Date date)
Sets a new Device Date and Timestatic boolean
setDefaultHomePage(String homePage)
Sets the default Browser Homepagestatic boolean
setDefaultLauncher(String packageName)
Specifies a new Default Launcherstatic boolean
setKeyboard(String keyboardName)
Sets the default and current Keyboard on this device.static boolean
setNewScanSettings(String settingsFilePath)
Apply new Barcode Scanner Settings from file.static boolean
setPreferredApn(String name)
Sets a new preferred Access Point Name (APN) configuration for a carrier data connections.static boolean
setScreenLockTimeout(int milliseconds)
Specifies a new Screen Lock Timeout in Millisecondsstatic boolean
setTimeZone(TimeZone timeZone)
Sets a new Device Time Zone from a specified android.icu.util.TimeZonestatic boolean
setTimeZone(String timeZoneID)
Sets a new Device Time Zone from a specified TimeZone IDstatic boolean
setTimeZone(TimeZone timeZone)
Sets a new Device Time Zone from a specified java.util.TimeZonestatic boolean
shutdown()
Performs a device shutdownstatic boolean
testMessage(String message)
Displays a Toast Message containing the specified String.static boolean
uninstallPackage(String packageName)
Uninstalls an app by it's package name.static boolean
updateApn(APN apn)
Updates an existing Access Point Name (APN) configuration for a carrier data connection.static boolean
updateNetwork(WifiConfiguration wifiConfiguration)
Update an existing network description of the set of configured networks.static boolean
verifyApn(String name)
Updates an existing Access Point Name (APN) configuration for a carrier data connection.static boolean
writeFile(ReadWriteFileParams readWriteFileParams)
Writes Data to a File
-
Method Details
-
isMethodSupported
Check whether theMethod
indicated by theBigInteger
method parameter is supported on the currently active device- Parameters:
method
-BigInteger
: Constant referencing the method to be checked- Returns:
boolean
:true
if the method is supported on the currently active device, otherwisefalse
- Throws:
IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.
-
isMethodSupported
Check whether theMethod
indicated by theString
methodName parameter is supported on the currently active device- Parameters:
methodName
-String
: Name of the method to be checked- Returns:
boolean
:true
if the method is supported on the currently active device, otherwisefalse
- Throws:
IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.
-
addNetwork
public static boolean addNetwork(WifiConfiguration wifiConfiguration) throws RemoteException, UnsupportedOperationExceptionAdd a new network description to the set of configured networks. ThenetworkId
field of the supplied configuration object is ignored.- Parameters:
wifiConfiguration
-WifiConfiguration
: The set of variables that describe the configuration, contained in a WifiConfiguration object- Returns:
- boolean whether or not the new network could be added
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
allowUnknownSources
public static boolean allowUnknownSources(boolean allow) throws RemoteException, UnsupportedOperationExceptionSpecifies whether applications from "unknown sources" (not from Google Play) can be installed on the device- Parameters:
allow
-boolean
: true allows unknown sources, false disallows them- Returns:
- boolean whether or not the Setting could be applied
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
clearCacheForPackage
public static boolean clearCacheForPackage(String packageName) throws RemoteException, UnsupportedOperationExceptionClears the Cache of an Application given by it's package name.- Parameters:
packageName
-String
: Package Name of the App which's cache shall be cleared.- Returns:
boolean
whether or not the app cache could be cleared successfully.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
clearClipboard
Clears the device's Clipboard- Returns:
- boolean whether or not the Clipboard could be cleared
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
clearDataForPackage
public static boolean clearDataForPackage(String packageName) throws RemoteException, UnsupportedOperationExceptionClears the Data of an Application given by it's package name.- Parameters:
packageName
-String
: Package Name of the App which's data shall be cleared.- Returns:
boolean
whether or not the app data could be cleared successfully.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
clearPassword
Clears the device password (PIN)- Returns:
- boolean whether or not the Password could be cleared
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
connectNetwork
public static boolean connectNetwork(String ssid) throws RemoteException, UnsupportedOperationExceptionConnects to an existing network according to it'sSSID
.- Parameters:
ssid
-String
: TheSSID
of the network to connect to- Returns:
- boolean whether or not the connection could be established
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
connectNetworkId
public static boolean connectNetworkId(int networkId) throws RemoteException, UnsupportedOperationExceptionConnects to an existing network according to it'snetworkId
.- Parameters:
networkId
-int
: ThenetworkId
of the network to connect to- Returns:
- boolean whether or not the connection could be established
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
copyFile
public static Path copyFile(Path sourceFilePath, Path destinationFilePath, CopyOption... options) throws RemoteException, UnsupportedOperationExceptionCopies a file from one location to another, with a variable number ofStandardCopyOptions
and/orLinkOptions
applied- Parameters:
sourceFilePath
-Path
: Path to copy the file fromdestinationFilePath
-Path
: Path to copy the file tooptions
- variable number ofStandardCopyOptions
and/orLinkOptions
to apply- Returns:
Path
to the target file ornull
if operation failed- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
- API Note:
- This method follows the specification of the Android API
copy
method.
It's purpose is to give user applications the ability to copy files which are out of reach for non-system apps.Requires Android O (Android 8) or later.
If you call this method on a device running an earlier version of Android, this method will returnnull
.
-
createNewApn
public static boolean createNewApn(APN apn, boolean setAsDefault) throws RemoteException, UnsupportedOperationExceptionCreates a new Access Point Name (APN) configuration for a carrier data connection and optionally sets it as the new default configuration.- Parameters:
apn
-APN
: The Access Point Name (APN) configuration for a carrier data connection.setAsDefault
-boolean
: Whether or not the APN configuration should become the new default configuration.- Returns:
- boolean whether or not the new Access Point Name (APN) configuration has been created successfully
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
deleteFile
public static boolean deleteFile(String filePath) throws RemoteException, UnsupportedOperationExceptionRemoves the specified file- Parameters:
filePath
-String
: Path (including name) of the file to be removed- Returns:
- boolean whether or not the file has been removed successfully
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
- API Note:
- Requires Android O (Android 8) or later.
If you call this method on a device running an earlier version of Android, this method will returnfalse
.
-
enableAdb
public static boolean enableAdb(boolean enable) throws RemoteException, UnsupportedOperationExceptionEnable / disables the ADB connectivity via USB- Parameters:
enable
-boolean
:true
enables ADB connectivity via USB,false
disables it- Returns:
- boolean whether or not the ADB connectivity via USB was enabled/disabled successfully.
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableApplication
public static boolean enableApplication(String packageName, boolean enable) throws RemoteException, UnsupportedOperationExceptionEnables / Disables a System Application given by it's package name.- Parameters:
packageName
-String
: Package Name of the System App which shall be enabled/disabled.enable
-boolean
: True enables the System App, false disables it.- Returns:
boolean
whether or not the app could be enabled/disabled successfully.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableBackgroundData
public static boolean enableBackgroundData(boolean enable) throws RemoteException, UnsupportedOperationExceptionSpecifies whether or not Background Data use is permitted- Parameters:
enable
-boolean
: true enables Background Data, false disables it- Returns:
- boolean whether or not the setting was applied successfully
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableBatteryOptimization
public static boolean enableBatteryOptimization(String packageName, boolean enable) throws RemoteException, UnsupportedOperationExceptionEnables / Disables a Battery Optimization ("Doze Mode") for an Application given by it's package name.
This adds/removes the given application to/from the system's whitelist of Apps which are not subject of battery optimization.- Parameters:
packageName
-String
: Package Name of the System App which shall be added/removed to/from the doze mode whitelist.enable
-boolean
: True adds the app to the doze mode whitelist, false removes it from the doze mode whitelist.- Returns:
boolean
whether or not the app could be added/removed to/from the doze mode whitelist successfully.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableBluetooth
public static boolean enableBluetooth(boolean enabled) throws RemoteException, UnsupportedOperationExceptionEnables/Disables Bluetooth on demandIf the requested state equals the current state of Bluetooth, the method returns true without performing any action.
- Parameters:
enabled
-boolean
: true enables Bluetooth, false disables it- Returns:
- boolean whether or not Bluetooth could be enabled/disabled
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableCameras
public static boolean enableCameras(boolean enable) throws RemoteException, UnsupportedOperationExceptionSpecifies whether or not the Device Cameras can be used- Parameters:
enable
-boolean
: true enables the Camera usage, false disables it- Returns:
- boolean whether or not the setting was applied successfully
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableClipboard
public static boolean enableClipboard(boolean enable) throws RemoteException, UnsupportedOperationExceptionEnable / disables the Clipboard- Parameters:
enable
-boolean
:true
enables the Clipboard,false
disables it- Returns:
- boolean whether or not the Clipboard was enabled/disabled successfully.
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableDeveloperMode
public static boolean enableDeveloperMode(boolean enabled) throws RemoteException, UnsupportedOperationExceptionEnables/Disables Developer Mode on demandIf the requested state equals the current state of Developer Mode, the method returns true without performing any action.
- Parameters:
enabled
-boolean
: true enables Developer Mode, false disables it- Returns:
- boolean whether or not Developer Mode could be enabled/disabled
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableDeviceAdmin
public static boolean enableDeviceAdmin(String packageName, String className, boolean makeAdmin) throws RemoteException, UnsupportedOperationExceptionEnables/Disables Device Admin Mode for specific apps/packages on demandNote that you must know both the package name of the app you want to enable/disable device admin mode upon, as well as the Class within that application that implements the DeviceAdminReceiver.
This is not the same as the Activity class name required to launch the application and would likely need to be acquired from the application developer.- Parameters:
packageName
-String
: The package name of the app in question where you want to enable/disable device admin mode upon.className
-String
: The class name of the Class within that application that implements the DeviceAdminReceiver.makeAdmin
-boolean
: true enables device admin mode on the application, false disables it.- Returns:
- boolean whether or not Device Admin Mode could be enabled/disabled on the application in question.
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableGps
public static boolean enableGps(boolean enabled) throws RemoteException, UnsupportedOperationExceptionEnables/Disables GPS on demandIf the requested state equals the current state of GPS, the method returns true without performing any action.
- Parameters:
enabled
-boolean
: true enables GPS, false disables it- Returns:
- boolean whether or not GPS could be enabled/disabled
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableMassStorage
public static boolean enableMassStorage(boolean enable) throws RemoteException, UnsupportedOperationExceptionEnable / disables the "USB Mass Storage" aka "File Transfer" mode- Parameters:
enable
-boolean
:true
enables the "USB Mass Storage" mode,false
disables it- Returns:
- boolean whether or not the "USB Mass Storage" mode was enabled/disabled successfully.
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableNfc
public static boolean enableNfc(boolean enabled) throws RemoteException, UnsupportedOperationExceptionEnables/Disables NFC on demandIf the requested state equals the current state of NFC, the method returns true without performing any action.
- Parameters:
enabled
-boolean
: true enables NFC, false disables it- Returns:
- boolean whether or not NFC could be enabled/disabled
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableRoaming
public static boolean enableRoaming(boolean enable) throws RemoteException, UnsupportedOperationExceptionSpecifies whether or not Data Roaming is available- Parameters:
enable
-boolean
: true enables Data Roaming false disables it- Returns:
- boolean whether or not the setting was applied successfully
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableWifi
public static boolean enableWifi(boolean enabled) throws RemoteException, UnsupportedOperationExceptionEnables/Disables Wifi on demandIf the requested state equals the current state of Wifi, the method returns true without performing any action.
- Parameters:
enabled
-boolean
: true enables Wifi, false disables it- Returns:
- boolean whether or not Wifi could be enabled/disabled
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
enableWwan
public static boolean enableWwan(boolean enabled) throws RemoteException, UnsupportedOperationExceptionEnables/Disables WWAN (3G/LTE/...) on demandIf the requested state equals the current state of WWAN, the method returns true without performing any action.
- Parameters:
enabled
-boolean
: true enables WWAN, false disables it- Returns:
- boolean whether or not WWAN could be enabled/disabled
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
- API Note:
- Requires Android O (Android 8) or later.
If you call this method on a device running an earlier version of Android, this method will returnfalse
.
-
factoryReset
public static boolean factoryReset(boolean removeAccounts) throws RemoteException, UnsupportedOperationExceptionPerforms a factory reset of the device- Parameters:
removeAccounts
-boolean
: Specifies whether or not to remove all Google Accounts prior to performing the Factory Reset.
IfremoveAccounts
is set to "true", all Google Accounts will be removed from the device before the Factory Reset is being performed, meaning that the device will not enter FRP after performing the reset.
IfremoveAccounts
is set to "true" and it's not possible to remove all Google Accounts prior to performing the Factory Reset, the method will returnfalse
and the device will not perform the Factory Reset.
This is to prevent the device from accidentally falling into FRP mode. IfremoveAccounts
is set to "false", existing Google Accounts will remain untouched and the device will simply perform the Factory Reset. This means that if aGoogle Accounts was present at the time of callingfactoryReset(false)
, the device will fall into FRP mode after reboot has finished.- Returns:
- boolean whether or not the Factory Reset could be performed
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
- API Note:
- There will be no warning or any confirmation dialog whatsoever when you call this method.
The device will simply, irrevocably, silently reboot and wipe the device.CAUTION: This wipes all data off the device!
CAUTION: If there's a Google Account active on the device at factory reset time, you will need to login to that account after reboot (Google Factory Reset Protection)!
-
getAllApnList
Gets theArray
of existingAccess Point Name (APN)
configurations.- Returns:
APN[]
Array
of available Access Point Name (APN) configurations.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
-
getApn
Gets theAccess Point Name (APN) configuration
for a carrier data connection by it'sname
.- Parameters:
name
-String
: Thename
field of the Access Point Name (APN) configuration in question for a carrier data connection.- Returns:
APN
the Access Point Name (APN) configuration for a carrier data connection. If no matching configuration for thename
could be found, the method returnsnull
.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
-
getApnId
Gets theid
field of an existing Access Point Name (APN) configuration for a carrier data connection.- Parameters:
name
-String
: Thename
field of the Access Point Name (APN) configuration in question for a carrier data connection.- Returns:
int
theid
field of an existing Access Point Name (APN) configuration for a carrier data connection. If no matching configuration for thename
could be found, the method returnsINVALID_APN (-1)
.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
-
getCurrentAndSetNewScanSettings
public static boolean getCurrentAndSetNewScanSettings(String settingsFilePath) throws RemoteException, UnsupportedOperationExceptionReads current Barcode Scanner settings and applies new Barcode Scanner settings to/from files according to the specified file pathNOTE: The Filename for the old Barcode Scanner setting will get a suffix "_old" applied.
SeegetCurrentScanSettings(String settingsFilePath)
andsetNewScanSettings(String settingsFilePath)
for further details regarding file name and file format specifications- Parameters:
settingsFilePath
-String
: Path to the file holding the Scanner settings- Returns:
- boolean whether or not the Barcode Scanner settings could be written to (a) file(s) and the new settings could applied to the Barcode Scanner successfully
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
getCurrentScanSettings
public static boolean getCurrentScanSettings(String settingsFilePath) throws RemoteException, UnsupportedOperationExceptionWrite current Barcode Scanner Settings to fileNOTE: The file may or may not contain a file extension.
If the file contains an extension (case insensitive), the generated settings file will have the following format:
* XML if the file extension is not ".json"
* JSON if the file extension is ".json"
If the file contains no extension, two settings files with be created with ".xml" and ".json" extension and
appropriate format accordingly.
The Filename will get a suffix "_cur" applied- Parameters:
settingsFilePath
-String
: Path to the file holding the Scanner settings- Returns:
- boolean whether or not the current Barcode Scanner settings could be written to (a) file(s) successfully
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
getGoogleAccounts
- Returns:
Array
ofAccount
: TheArray
of existing GoogleAccounts
currently configured for this device.
In case of failure, this method returnsnull
.
If no GoogleAccounts
are configured at the time of calling this method, the return value will be an emptyArray
.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
-
getKeyboardNames
- Returns:
List
ofString
The Package Names of the available Keyboards on this device. In case of an error, the method returnsnull
.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
-
initializeKeyStore
public static boolean initializeKeyStore(String storeName, String password) throws RemoteException, UnsupportedOperationExceptionInitialize the given CertificateKeyStore
with the given Password.- Parameters:
storeName
-String
: Friendly name of the CertificateKeyStore
to be initialized.
Can benull
or an emptyString
, in which case the defaultKeyStore
will be used.password
-String
: Password to be used for theKeyStore
.- Returns:
boolean
whether or not the CertificateKeyStore
could be initialized successfully.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
installApk
public static boolean installApk(String apkFilename, boolean update) throws RemoteException, UnsupportedOperationExceptionInstalls an app by it's apk file name.- Parameters:
apkFilename
-String
: File name of the .apk file to be installed.update
-boolean
: Whether or not to update the app if it's already installed.
If you specify "true" but the app is not installed yet, this parameter will have no effect.
If you specify "false" but the app is already installed, this method will return false and the installation will fail.- Returns:
boolean
whether or not the .apk file could be installed successfully.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
installCertificate
public static boolean installCertificate(String friendlyName, String fileName) throws RemoteException, UnsupportedOperationExceptionInstalls a Certificate from a File.- Parameters:
friendlyName
-String
: Friendly name of the Certificate to be installed.fileName
-String
: File Path and Name of the Certificate File.- Returns:
boolean
whether or not the Certificate could be installed successfully.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 2.00
-
lockDevice
Locks the Device (i.e. device needs to be unlocked to be used further on)May or may not turn off the display, depending on device settings
- Returns:
boolean
whether or not the Device could be locked- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
mountSDCard
public static boolean mountSDCard(boolean mount) throws RemoteException, UnsupportedOperationExceptionMounts/Unmounts the external SD Card- Parameters:
mount
-boolean
: true mounts the external SD card, false unmounts it- Returns:
- boolean whether or not the external SD card could (un)mounted successfully.
- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
moveFile
public static Path moveFile(Path sourceFilePath, Path destinationFilePath, CopyOption... options) throws RemoteException, UnsupportedOperationExceptionMoves a file from one location to another, with a variable number ofStandardCopyOptions
applied- Parameters:
sourceFilePath
-Path
: Path to move the file fromdestinationFilePath
-Path
: Path to move the file tooptions
- variable number ofStandardCopyOptions
to apply- Returns:
Path
to the target file ornull
if operation failed- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
- API Note:
- This method follows the specification of the Android API
move
method.
It's purpose is to give user applications the ability to move files which are out of reach for non-system apps.Requires Android O (Android 8) or later.
If you call this method on a device running an earlier version of Android, this method will returnnull
.
-
readFile
public static boolean readFile(ReadWriteFileParams readWriteFileParams) throws RemoteException, UnsupportedOperationExceptionReads Data from a FileThe
readWriteFileParams
parameter holds a set of parameters used to read the data from the given file.Since this method uses a variable set of parameters with overlapping parameter types, overloading methods or using variable argument lists isn't feasible.
Instead, thereadWriteFileParams
holds a set of all required parameters for this method.Use
ReadWriteFileParams.Builder
to create a new instance of thereadWriteFileParams
parameter.The example below shows how you might create a new
ReadWriteFileParams
object instance for use with this method:// Create a ReadWriteFileParams object instance with a data buffer of 4K, // for read operation starting after 1 byte, accessing the buffer from index 2 onwards, reading a hundred bytes. byte[] testData = new byte[4096]; ReadWriteFileParams readWriteFileParams = ReadWriteFileParams.setPath(Paths.get("/sdcard/Download/devinfo.html")) .setData(testData) .setFileOffset(1) .setDataOffset(2) .setLength(100) .setOptions(StandardOpenOption.READ) .build(); EDTLib.readFile(readWriteFileParams);
- Parameters:
readWriteFileParams
-ReadWriteFileParams
: Parameters specifying which file to read from, with optional data buffer, offsets, length and File Options.- Returns:
boolean
whether or not the file data has been read successfully- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
- See Also:
ReadWriteFileParams for further details.
- API Note:
- the
data buffer
ofreadWriteFileParams
is optional.
If this method is called with a data buffer provided, the method call will fail if the data buffer is insufficient to hold the data being read.
If this method is called without providing a data buffer i.e. when getData() equalsnull
, the method call will dynamically allocate a buffer holding the data being read.Requires Android O (Android 8) or later.
If you call this method on a device running an earlier version of Android, this method will returnfalse
.
-
reboot
Performs a device reboot- Returns:
boolean
whether or not the Reboot could be performed- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
- API Note:
- There will be no warning or any confirmation dialog whatsoever when you call this method.
The device will simply, irrevocably, silently reboot, quite like when the user keeps pressing the power key and chooses to "Reboot".
-
recovery
Performs a device reboot into recovery mode- Returns:
boolean
whether or not the Recovery Reboot could be performed- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
- API Note:
- There will be no warning or any confirmation dialog whatsoever when you call this method.
The device will simply, irrevocably, silently reboot into recovery mode, quite like when the user keeps pressing the power key and chooses to "Reboot" - but using this method it will not reboot the Operating System, but reboot into recovery mode instead.
-
rememberPasswords
public static boolean rememberPasswords(boolean enable) throws RemoteException, UnsupportedOperationExceptionSpecifies whether or not the Browser may remember Login Passwords- Parameters:
enable
-boolean
: true enables remembering Login Passwords, false disables it- Returns:
boolean
whether or not the setting was applied successfully- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
removeAccount
public static boolean removeAccount(Account account) throws RemoteException, UnsupportedOperationExceptionRemoves (attempts to remove) a certain account from the device- Parameters:
account
-Account
: Account to be removed- Returns:
boolean
whether or not the account removal was successful- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
removeAllAccounts
Removes (attempts to remove) all configured accounts of all kind from the device- Returns:
boolean
whether or not the account removal was successful- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
- API Note:
- This method usually fails, because certain accounts cannot be removed.
Those that can be removed will be removed nevertheless.
-
removeAllGoogleAccounts
public static boolean removeAllGoogleAccounts() throws RemoteException, UnsupportedOperationExceptionRemoves (attempts to remove) all configured Google accounts from the device- Returns:
boolean
whether or not the account removal was successful- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
removeNetwork
public static boolean removeNetwork(String ssid) throws RemoteException, UnsupportedOperationExceptionRemoves an existing network according to it'sSSID
.- Parameters:
ssid
-String
: TheSSID
of the network to be removed- Returns:
boolean
whether or not the existing network could be removed- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
removeNetworkId
public static boolean removeNetworkId(int networkId) throws RemoteException, UnsupportedOperationExceptionRemoves an existing network according to it'snetworkId
.- Parameters:
networkId
-int
: ThenetworkId
of the network to be removed- Returns:
boolean
whether or not the existing network could be removed- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
resetPassword
public static boolean resetPassword(String newPassword) throws RemoteException, UnsupportedOperationExceptionResets the device password (PIN) to a new value- Parameters:
newPassword
-String
: The new Device Password to be set- Returns:
boolean
whether or not the new Password could be set- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
saveFormData
public static boolean saveFormData(boolean enable) throws RemoteException, UnsupportedOperationExceptionSpecifies whether or not the Browser may save Form Input Data- Parameters:
enable
-boolean
: true enables saving Form Input Data, false disables it- Returns:
boolean
whether or not the setting was applied successfully- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
setDateTime
Sets a new Device Date and Time- Parameters:
date
-Date
: The Date and Time to be set- Returns:
boolean
whether or not the new Date/Time could be set- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
- API Note:
- Requires Android N (Android 7) or later.
If you call this method on a device running an earlier version of Android, this method will returnfalse
.
-
setDefaultHomePage
public static boolean setDefaultHomePage(String homePage) throws RemoteException, UnsupportedOperationExceptionSets the default Browser Homepage- Parameters:
homePage
-String
: URL of the new Homepage- Returns:
boolean
whether or not the default Browser Homepage could be set successfully- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
setDefaultLauncher
public static boolean setDefaultLauncher(String packageName) throws RemoteException, UnsupportedOperationExceptionSpecifies a new Default Launcher- Parameters:
packageName
-String
: Package Name of the new Default Launcher- Returns:
boolean
whether or not the Default Launcher was set successfully- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
setKeyboard
public static boolean setKeyboard(String keyboardName) throws RemoteException, UnsupportedOperationExceptionSets the default and current Keyboard on this device.- Parameters:
keyboardName
-String
: The Package Name of the Keyboard to be used.
UsegetKeyboardNames()
to fetch aList
of available Keyboard Names.- Returns:
boolean
whether or not the Keyboard was set successfully- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
setNewScanSettings
public static boolean setNewScanSettings(String settingsFilePath) throws RemoteException, UnsupportedOperationExceptionApply new Barcode Scanner Settings from file.NOTE: The file may or may not contain a file extension.
If the file contains an extension (case insensitive), the settings will be parsed from the following format:
* XML if the file extension is ".xml"
* JSON if the file extension is ".json"
* Dynamically XML or JSON (XML is attempted first, in case of failure another attempt is made to parse JSON format) if the file extension is neither ".xml" nor ".json"
If the file contains no extension, two settings will dynamically be parsed in XML or JSON format (XML is attempted first, in case of failure another attempt is made to parse JSON format)- Parameters:
settingsFilePath
-String
: Path to the file holding the Scanner settings- Returns:
boolean
whether or not the new settings could applied to the Barcode Scanner- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
setPreferredApn
public static boolean setPreferredApn(String name) throws RemoteException, UnsupportedOperationExceptionSets a new preferred Access Point Name (APN) configuration for a carrier data connections.- Parameters:
name
-String
: Thename
field of the Access Point Name (APN) configuration in question for becoming the new preferred carrier data connection.- Returns:
boolean
whether or not the Access Point Name (APN) configuration in question could be set as the new preferred APN configuration.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
setScreenLockTimeout
public static boolean setScreenLockTimeout(int milliseconds) throws RemoteException, UnsupportedOperationExceptionSpecifies a new Screen Lock Timeout in Milliseconds- Parameters:
milliseconds
-int
: The new Screen Lock Timeout Value in Milliseconds- Returns:
boolean
whether or not the Screen Lock Timeout was set successfully- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
setTimeZone
public static boolean setTimeZone(TimeZone timeZone) throws RemoteException, UnsupportedOperationExceptionSets a new Device Time Zone from a specified android.icu.util.TimeZone- Parameters:
timeZone
-android.icu.util.TimeZone
: The new Time Zone to be set- Returns:
boolean
whether or not the new Time Zone could be set- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
- API Note:
- Requires Android N (Android 7) or later.
Devices running Android M (Android 6) or earlier should usesetTimeZone(java.util.TimeZone timeZone)
instead. If you call this method on a device running an earlier version of Android, this method will returnfalse
.
-
setTimeZone
public static boolean setTimeZone(TimeZone timeZone) throws RemoteException, UnsupportedOperationExceptionSets a new Device Time Zone from a specified java.util.TimeZone- Parameters:
timeZone
-java.util.TimeZone
: The new Time Zone to be set- Returns:
boolean
whether or not the new Time Zone could be set- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 2.02
- API Note:
- This Method is meant to be used on devices running Requires Android M (Android 6) or earlier.
Devices running Android N (Android 7) or later should usesetTimeZone(android.icu.util.TimeZone timeZone)
instead.
-
setTimeZone
public static boolean setTimeZone(String timeZoneID) throws RemoteException, UnsupportedOperationExceptionSets a new Device Time Zone from a specified TimeZone ID- Parameters:
timeZoneID
-String
: The ID of the new Time Zone to be set.
Useandroid.icu.util.TimeZone.getAvailableIDs()
orjava.util.TimeZone.getAvailableIDs()
to get a list of available TimeZone IDs on your device.- Returns:
boolean
whether or not the new Time Zone could be set- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 2.02
-
shutdown
Performs a device shutdown- Returns:
boolean
whether or not the Shutdown could be performed- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
- API Note:
- There will be no warning or any confirmation dialog whatsoever when you call this method.
The device will simply, irrevocably, silently power off, quite like when the user keeps pressing the power key and chooses to "Power off".
-
testMessage
public static boolean testMessage(String message) throws RemoteException, UnsupportedOperationExceptionDisplays a Toast Message containing the specified String.This method is supposed to be used for testing purpose only, for instance in order to check whether the service binding from a sample application is working or not.
- Parameters:
message
-String
: The Message to be displayed- Returns:
boolean
whether or not the Message could be shown- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
updateApn
Updates an existing Access Point Name (APN) configuration for a carrier data connection.- Parameters:
apn
-APN
: The Access Point Name (APN) configuration for a carrier data connection, holding the new data for this configuration.
The "id" field holds the ID of the existing APN configuration to be updated.
UsegetApnId
to fetch the ID from a given name if required.- Returns:
boolean
whether or not the new Access Point Name (APN) configuration has been applied successfully.
If no matching configuration for the ID could be found, the method returnsfalse
.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
updateNetwork
public static boolean updateNetwork(WifiConfiguration wifiConfiguration) throws RemoteException, UnsupportedOperationExceptionUpdate an existing network description of the set of configured networks. ThenetworkId
field must be set to the ID of the existing network being updated.- Parameters:
wifiConfiguration
-WifiConfiguration
: The set of variables that describe the configuration, contained in a WifiConfiguration object. It may be sparse, so that only the items that are being changed are non-null.- Returns:
boolean
whether or not the existing network could be updated- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
uninstallPackage
public static boolean uninstallPackage(String packageName) throws RemoteException, UnsupportedOperationExceptionUninstalls an app by it's package name.- Parameters:
packageName
-String
: Package Name of the App to be uninstalled.- Returns:
boolean
whether or not the app could be uninstalled successfully.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
verifyApn
Updates an existing Access Point Name (APN) configuration for a carrier data connection.- Parameters:
name
-String
: Thename
field of the Access Point Name (APN) configuration in question for a carrier data connection.- Returns:
boolean
whether or not the Access Point Name (APN) configuration in question refers to a valid APN configuration.- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.- Since:
- 1.00
-
writeFile
public static boolean writeFile(ReadWriteFileParams readWriteFileParams) throws RemoteException, UnsupportedOperationExceptionWrites Data to a FileThe
readWriteFileParams
parameter holds a set of parameters used to write the data to the given file.Since this method uses a variable set of parameters with overlapping parameter types, overloading methods or using variable argument lists isn't feasible.
Instead, thereadWriteFileParams
holds a set of all required parameters for this method.Use
ReadWriteFileParams.Builder
to create a new instance of thereadWriteFileParams
parameter.The example below shows how you might create a new
ReadWriteFileParams
object instance for use with this method:// Create a ReadWriteFileParams object instance with a data buffer of 4K, // for write operation starting after 1 byte, accessing the buffer from index 2 onwards, writing a hundred bytes. byte[] testData = new byte[4096]; ReadWriteFileParams readWriteFileParams = ReadWriteFileParams.setPath(Paths.get("/sdcard/Download/devinfo.html")) .setData(testData) .setFileOffset(1) .setDataOffset(2) .setLength(100) .setOptions(StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE) .build(); EDTLib.writeFile(readWriteFileParams);
- Parameters:
readWriteFileParams
-ReadWriteFileParams
: Parameters specifying which file to write to, with mandatory data buffer and optional offsets, length and File Options.- Returns:
boolean
whether or not the file data has been written successfully- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.IllegalStateException
- Gets thrown when the Library is not ready yet to accept method calls.
In such case, please useonLibraryReady
Method to add acallback
which then processes this method. See API Notes ofthis class
for further details.- Since:
- 1.00
- See Also:
ReadWriteFileParams for further details.
- API Note:
- the
data buffer
ofreadWriteFileParams
is mandatory.
If this method is called with a data buffer provided, the method call will fail if the data buffer is insufficient to write the specified amount of data.
If this method is called without providing a data buffer i.e. when getData() equalsnull
, the method call will fail.Requires Android O (Android 8) or later.
If you call this method on a device running an earlier version of Android, this method will returnfalse
.
-
onLibraryReady
public static void onLibraryReady(LibraryCallback callback) throws RemoteException, UnsupportedOperationExceptionAdd a new Callback to the Queue of Callbacks to be processed once the EDT Service becomes available- Parameters:
callback
-LibraryCallback
: Instance of theLibraryCallback
Interface which holds theonLibraryReady()
Method which will get called once the regarding library becomes available- Throws:
RemoteException
- Gets thrown when access to the system service fails.UnsupportedOperationException
- Gets thrown when the current device does not support this method.
-