Skip to content

Instantly share code, notes, and snippets.

View jignesh8992's full-sized avatar
🏠
Working from home

Jignesh N Patel jignesh8992

🏠
Working from home
  • Vasundhara Infotech LLP
  • Navsari, Gujarat, India
  • X @jignesh8992
View GitHub Profile
@fiftyonemoon
fiftyonemoon / AndroidXI
Created July 12, 2021 14:57
File create, rename, duplicate and delete in Android11.
import android.app.PendingIntent;
import android.app.RecoverableSecurityException;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.IntentSender;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
@AlexZhukovich
AlexZhukovich / Analytics.kt
Last active October 6, 2022 14:23
Android ProcessLifecycleOwner 
by example - source code for article https://alexzh.com/2019/08/19/android-processlifecycleowner-by-example/
class Analytics {
private var startSessionTimestamp: Long = -1
private val reporters = mutableListOf<AnalyticsReporter>()
fun addReporter(reporter: AnalyticsReporter) {
reporters.add(reporter)
}
fun startSession() {
startSessionTimestamp = Date().time
@ernestkamara
ernestkamara / AdbCommands
Created June 26, 2018 08:42 — forked from Pulimet/AdbCommands
Adb useful commands list
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell
package com.github.irshulx.glitchtext;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
@scottTomaszewski
scottTomaszewski / AsyncTaskWithTimeout.java
Last active April 6, 2021 03:48
Extension of Android's AsyncTask which adds support for timeout
package com.grok.notes.util;
import android.app.Activity;
import android.os.AsyncTask;
import android.util.Log;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@mrhether
mrhether / OnSingleClickListener.java
Created May 9, 2016 19:46
OnSingleClickListener
/**
* Implementation of {@link OnClickListener} that ignores subsequent clicks that happen too quickly after the first one.<br/>
* To use this class, implement {@link #onSingleClick(View)} instead of {@link OnClickListener#onClick(View)}.
*/
public abstract class OnSingleClickListener implements OnClickListener {
private static final String TAG = OnSingleClickListener.class.getSimpleName();
private static final long MIN_DELAY_MS = 500;
private long mLastClickTime;
@tatocaster
tatocaster / RealPathUtil.java
Last active January 31, 2026 10:00
Real Path Utility class for Android, works for all API
public class RealPathUtil {
public static String getRealPath(Context context, Uri fileUri) {
String realPath;
// SDK < API11
if (Build.VERSION.SDK_INT < 11) {
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri);
}
// SDK >= 11 && SDK < 19
else if (Build.VERSION.SDK_INT < 19) {
@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 {
//activity.xml
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/sb_progress"
android:progressDrawable="@drawable/custom_seek_bar"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:minHeight="8dip"//important!
android:maxHeight="8dip"//important!
@Antarix
Antarix / TouchImageView.java
Created June 10, 2014 10:30
Android extended (Zoom in,Zoom out) ImageView with Double tap and pinch gesture
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.net.Uri;