Skip to content

Instantly share code, notes, and snippets.

@TechNov
TechNov / DeCryptor.java
Created July 7, 2021 14:36 — forked from piyush-malaviya/DeCryptor.java
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/
@TechNov
TechNov / DeCryptor.java
Created July 7, 2021 14:36 — forked from JosiasSena/DeCryptor.java
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexUtils {
//private static final String DISTANCE_PATTERN = "(?i)[0-9]{1,2}\\s??(?:mi|mile|miles|km)\\b";
private static final String DISTANCE_PATTERN = "(?i)((?:\\d+)?\\.?\\d+)\\s??(?:mi|mile|miles|km)\\b";
private static final String DISTANCE_UNIT_PATTERN = "(?i)(?:mi|mile|miles|km)\\b";
private static final String TIME_PATTERN = "(?i)[0-9]{1,2}\\s??(?:min|hr)";
private static final String TIME_UNIT_PATTERN = "(?i)(?:min|hr)";
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.util.DisplayMetrics;
public class DisplayUtils {
private static DisplayUtils instance;
public static DisplayUtils getInstance() {
@TechNov
TechNov / MultiPartUtility.java
Created July 7, 2021 14:39 — forked from piyush-malaviya/MultiPartUtility.java
Uploading Multiple files at once with Post and Header parameter in Android
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.GestureDescription;
import android.content.Context;
import android.graphics.Path;
import android.graphics.Rect;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.RequiresApi;
import android.text.TextUtils;
import android.util.Log;
Stackoverflow Link: https://stackoverflow.com/a/19968400
Handle uncaughtException, start activity:
public class MyApplication extends Application
{
public void onCreate ()
{
// Setup handler for uncaught exceptions.
Thread.setDefaultUncaughtExceptionHandler (new Thread.UncaughtExceptionHandler()
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import android.util.Log;
import java.nio.charset.Charset;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.regex.Pattern;
public class StringUtils {
private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
import android.app.Activity;
import android.app.ActivityManager;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.provider.ContactsContract;
import android.provider.Settings;
import android.support.v4.app.Fragment;