Skip to content

Instantly share code, notes, and snippets.

View jaydipumaretiya's full-sized avatar
🧑‍💻
Coding

Jaydip Umaretiya jaydipumaretiya

🧑‍💻
Coding
View GitHub Profile
<?php
#API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-SERVER-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = $_GET['id'];
#prep the bundle
$msg = array
(
'body' => 'Body Of Notification',
'title' => 'Title Of Notification',
'icon' => 'myicon',/*Default Icon*/
@jaydipumaretiya
jaydipumaretiya / AppStart.java
Last active May 16, 2017 19:07
For checking app is run first time or new version is running first time
/**
* Distinguishes different kinds of app starts: <li>
* First start ever ({@link #FIRST_TIME})
* First start in this version ({@link #FIRST_TIME_VERSION})
* Normal app start ({@link #NORMAL})
*
* @author Jaydip
*/
public enum AppStart {
FIRST_TIME, FIRST_TIME_VERSION, NORMAL
@jaydipumaretiya
jaydipumaretiya / MainActivty.java
Created April 24, 2017 05:24
This is for set package name and other details free version and paid version.
if (BuildConfig.PAID_VERSION) {
// do paid version only stuff
}
@jaydipumaretiya
jaydipumaretiya / ChangeCursorColor.java
Created April 22, 2017 18:38
This method is use for change color of EditText.
public static void setCursorColor(EditText view, @ColorInt int color) {
try {
// Get the cursor resource id
Field field = TextView.class.getDeclaredField("mCursorDrawableRes");
field.setAccessible(true);
int drawableResId = field.getInt(view);
// Get the editor
field = TextView.class.getDeclaredField("mEditor");
field.setAccessible(true);
@jaydipumaretiya
jaydipumaretiya / DispatchTouchEvent.java
Created April 22, 2017 18:33
dispatchTouchEvent method for hide keyboard on touch.
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
View view = getCurrentFocus();
boolean ret = super.dispatchTouchEvent(event);
if (view instanceof EditText) {
View w = getCurrentFocus();
int scrcoords[] = new int[2];
w.getLocationOnScreen(scrcoords);
float x = event.getRawX() + w.getLeft() - scrcoords[0];
@jaydipumaretiya
jaydipumaretiya / ReadQRCodeWithOutCamera.java
Last active May 13, 2021 07:46
This is code for read QR code without camera. Just get image from gallery and get bitmap of that image and then pass it in this method.
private void readQRCode(Bitmap bMap) {
int width = bMap.getWidth();
int height = bMap.getHeight();
int[] pixels = new int[width * height];
bMap.getPixels(pixels, 0, width, 0, 0, width, height);
RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
try {