Skip to content

Instantly share code, notes, and snippets.

View pranaypatel512's full-sized avatar
๐Ÿ˜Ž
Working...

pRaNaY pranaypatel512

๐Ÿ˜Ž
Working...
View GitHub Profile
@gabrielemariotti
gabrielemariotti / README.md
Last active February 24, 2021 10:52
How to manage the support libraries in a multi-module projects. Thanks to Fernando Cejas (http://fernandocejas.com/)

Centralize the support libraries dependencies in gradle

Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.

A very good way is to separate gradle build files, defining something like:

root
  --gradleScript
 ----dependencies.gradle
@ftvs
ftvs / PhonecallReceiver.java
Last active December 25, 2025 04:34
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: Gabe Sechan http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@Mariovc
Mariovc / ImagePicker.java
Last active May 13, 2026 17:43
Utility for picking an image from Gallery/Camera with Android Intents
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
@fbis251
fbis251 / MainActivity.java
Created September 21, 2015 15:28
Android Glide + okhttp progress example
package com.example.glidetest.app;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ProgressBar;
import com.bumptech.glide.Glide;
import com.bumptech.glide.integration.okhttp.OkHttpUrlLoader;
@voghDev
voghDev / LogJsonInterceptor.java
Created October 29, 2015 12:51
retrofit2 interceptor that logs the raw JSON response from API. After that it clones it and returns a sane copy that other classes can consume.
import android.util.Log;
import com.appandweb.prjtestdrivendev.BuildConfig;
import com.squareup.okhttp.Interceptor;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import java.io.IOException;
/* Copyright 2013 Google Inc.
Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0.html
Source - https://gist.github.com/broady/6314689
Video - https://www.youtube.com/watch?v=WKfZsCKSXVQ&feature=youtu.be
*/
package xxx.xxxx.xxxxxx
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
@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);
@antoniomaria
antoniomaria / Splitter.java
Created January 25, 2016 08:28
Java split bytes array into chunks
byte[] data = { 2, 3, 5, 7, 8, 9, 11, 12, 13 };
int blockSize = 3;
int blockCount = (data.length + blockSize - 1) / blockSize;
byte[] range = null;
for (int i = 1; i < blockCount; i++) {
int idx = (i - 1) * blockSize;
range = Arrays.copyOfRange(data, idx, idx + blockSize);
@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 / 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 {