A collection of utility classes for the Android Platform.
<dependency>
<groupId>com.nityankhanna</groupId>
<artifactId>androidutils</artifactId>
<version>1.1</version>
</dependency>
ThreadPool threadPool = ThreadPool.getInstance();
threadPool.queueWorkerItem(new Runnable() {
@Override
public void run() {
Log.d("DEBUG", "I am running in a background thread");
}
});
HttpRequestMessage requestMessage = new HttpRequestMessage("http://example.com", RequestType.GET);
requestMessage.addHeader(new HttpHeader("Content-Type", "application/json;charset=UTF-8");
JSONObject body = new JSONObject();
body.put("key", "value");
body.put("key2", 1);
requestMessage.setJsonBody(body);
HttpClientService client = new HttpClientService(requestMessage, this);
client.executeRequestAsync();
ServiceManager serviceManager = ServiceManager.getInstance();
if (serviceManager.isBluetoothAvailable()) {
Log.d("DEBUG", "Bluetooth is available");
}
if (serviceManager.isNetworkAvailable()) {
Log.d("DEBUG", "Network is available");
}
StringUtils.toByteArray("this is a string");
StringUtils.toInt("1234");
StringUtils.isNullOrEmpty("Pretend Im NULL");
EncryptionManager encryptionManager = EncryptionManager.getInstance();
SecretKeySpec password = encryptionManager.createPassword("guest");
byte[] encryptedData = encryptionManager.encryptData(password, StringUtils.toByteArray("this is the data to encrypt");
byte[] decryptedData = encryptionManager.decryptData(password, encryptedData);
SharedPreferencesService sharedPreferences = new SharedPreferencesService(getApplicationContext());
sharedPreferences.setStringForKey("I'm the key", "I'm the value");
String data = sharedPreferences.getStringForKey("I'm the key");
SharedPreferencesService sharedPreferences = new SharedPreferencesService(getApplicationContext());
EncryptionManager encryptionManager = EncryptionManager.getInstance();
SecretKeySpec password = encryptionManager.createPassword("guest");
sharedPreferences.setPassword(password);
sharedPreferences.setSecureStringForKey("I'm the key", "I'm the value");