Skip to content

Instantly share code, notes, and snippets.

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

pRaNaY pranaypatel512

๐Ÿ˜Ž
Working...
View GitHub Profile
@Antarix
Antarix / FirebaseDataReceiver.java
Created November 21, 2016 10:22
Firebase Android Sample for managing notification
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.util.Log;
/**
* This is called whenever app receives notification
* in background/foreground state so you can
* apply logic for background task, but still Firebase notification
* will be shown in notification tray
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
@vincent1086
vincent1086 / gist:132d6411eda947eebc606fdd692e4e9f
Created August 28, 2016 10:41
Android - MapView inside ScrollView fix bug
public class ScrollMapView extends MapView {
private final static String TAG = "ScrollMapView";
public ScrollMapView(Context context) {
super(context);
}
public ScrollMapView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
@vxhviet
vxhviet / upsideDownTriangle.md
Created August 12, 2016 09:46
How to draw upside down triangle with xml.

Source: StackOverflow

Answer: Simple way to create an upside down triangle with xml.

Here it is XML for triangle and rectangle. save it inside drawable folder.

triangle.xml

<?xml version="1.0" encoding="utf-8"?>
@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 / 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;
@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 / 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);
/* 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;
@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;