Skip to content

Instantly share code, notes, and snippets.

View mumayank's full-sized avatar

Mayank Mohan Upadhyay mumayank

View GitHub Profile
try {
Field f;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
f = AbsListView.class.getDeclaredField("mFastScroll");
} else {
f = AbsListView.class.getDeclaredField("mFastScroller");
}
Object o = f.get(getListView());
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
classpath 'com.android.tools.build:gradle:2.1.3'
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
// line on the top of the file:
int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 15
// replace your earlier minSdkVersion <sdk version number> with:
minSdkVersion minSdk
-Pminsdk=23
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new CountClass().execute("name 1", "name 2", "name 3");
}
@mumayank
mumayank / Android AsyncTask Min
Last active October 2, 2017 18:18
Easily do background tasks, update UI during start, inbetween and in the end.
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new BgAsyncTask().execute(null, null, null);
}
public class ClientEncrypt {
private static String publicKeyString = "<your_public_key_here>";
public static void main (String args[]) {
try {
// 1. generate secret key using AES
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
keyGenerator.init(128); // AES is currently available in three key sizes: 128, 192 and 256 bits.The design and strength of all key lengths of the AES algorithm are sufficient to protect classified information up to the SECRET level
public class GenerateRsaKeyPair {
public static void main(String args[]) {
try {
// 1. generate public key and private key
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(1024); // key length
KeyPair keyPair = keyPairGenerator.genKeyPair();
String privateKeyString = Base64.encodeToString(keyPair.getPrivate().getEncoded(), Base64.DEFAULT);
String publicKeyString = Base64.encodeToString(keyPair.getPublic().getEncoded(), Base64.DEFAULT);
public class ServerDecrypt {
static String privateKey = "<your_private_key_here>";
static String encryptedTextString = "<your_received_encrypted_text_here>";
static String encryptedSecretKeyString = "<your_received_encrypted_secret_key_here>";
public static void main(String args[]) {
try {