Skip to content

Instantly share code, notes, and snippets.

View pranaypatel512's full-sized avatar
😎
Working...

pRaNaY pranaypatel512

😎
Working...
View GitHub Profile
@pranaypatel512
pranaypatel512 / Print KeyHash for Facebook
Created January 22, 2016 04:24
This is code to generate key hash which require in facebook sdk integration for sharing and signin with facebook.
public static String printKeyHash(Activity context) {
PackageInfo packageInfo;
String key = null;
try {
//getting application package name, as defined in manifest
String packageName = context.getApplicationContext().getPackageName();
//Retriving package info
packageInfo = context.getPackageManager().getPackageInfo(packageName,
PackageManager.GET_SIGNATURES);
@pranaypatel512
pranaypatel512 / PhoneNumberTextWatcher.java
Last active December 1, 2022 09:03
Custom TextWatcher for Accepting PhoneNumber in this (XXX-XXX-XXXX) format.
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
public class PhoneNumberTextWatcher implements TextWatcher {
private static final String TAG = "PhoneNumberTextWatcher";
private EditText editText;
@pranaypatel512
pranaypatel512 / ListUtils.java
Last active April 20, 2016 08:18
set list view height dynamically
package com.karconnect.app.utils;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;
/**
@pranaypatel512
pranaypatel512 / NetworkUtils.java
Last active July 8, 2016 09:39
network utils Class of an application
package com.karconnect.app.utils;
import android.content.Context;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.support.v7.app.AlertDialog;
public class NetworkUtils {
@pranaypatel512
pranaypatel512 / Encryption.java
Created April 20, 2016 07:31
[AES (acronym of Advanced Encryption Standard) is a symmetric encryption algorithm.
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
/**
@pranaypatel512
pranaypatel512 / PushFragment
Created April 28, 2016 06:42
This method is used for fragment transaction
/**
* push fragment
*
* @param fragment fragment
* @param animate fragment transition animation
* @param shouldAdd add to back stack
* @param tag fragment tag
*/
public void pushFragments(Fragment fragment, boolean animate, boolean shouldAdd, String tag) {
FragmentManager manager = getActivity().getSupportFragmentManager();
@pranaypatel512
pranaypatel512 / DialogUtils.java
Last active January 30, 2019 07:10
Show different type of dialog
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
<LinearLayout
...
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedResources" >
<TextView
android:text="@string/str_foo_string" />
</LinearLayout>
For SHA:
keytool -list -v -keystore '/home/../.android/debug.keystore' -alias androiddebugkey -storepass android -keypass android
For Facebook KeyHash:
keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
@pranaypatel512
pranaypatel512 / GifDecoder.java
Created July 18, 2017 18:05 — forked from devunwired/GifDecoder.java
An optimized implementation of GifDecoder for Android devices.
/**
* Copyright (c) 2013 Xcellent Creations, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions: