Skip to content

Instantly share code, notes, and snippets.


Tunji Olu-Taiwo tunjos

View GitHub Profile
tunjos /
Created May 26, 2021 04:13 — forked from AnatomicJC/
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Fetch application APK

To get the list of your installed applications:

tunjos /
Created August 13, 2020 11:32 — forked from wojteklu/
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.

General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

tunjos / app_build.gradle
Created July 13, 2016 20:00
Producing better named Android APKs with Gradle
View app_build.gradle
apply from: "../artifacts.gradle"
tunjos / app_build.gradle
Created July 13, 2016 19:39
Automatic versionCode generation in Android Gradle
View app_build.gradle
defaultConfig {
versionCode buildVersionCode()
versionName version
tunjos /
Created July 24, 2015 16:46
Creating a clean gh-pages branch

Creating a clean gh-pages branch

cd /path/to/repo-name
git checkout --orphan gh-pages
git rm -rf .
echo "My GitHub Page" > index.html
git add .
git commit -a -m "Add index.html"
tunjos / copyReleaseApkToCustomDir.gradle
Last active December 8, 2021 03:10
Copy release apk to custom directory
View copyReleaseApkToCustomDir.gradle
def publish = project.tasks.create("copyReleaseApkToCustomDir")
publish.description "Copies release apk to custom directory"
android.applicationVariants.all { variant ->
if ("release")) {
variant.outputs.each { output ->
if ( output.outputFile != null &&'.apk')) {
def task = project.tasks.create("copyAndRename${}Apk", Copy)
def outputFile = output.outputFile
println "Creating " + + "-${versionName}.apk" + " from " + + "-${}.apk"
tunjos / build.gradle
Created July 7, 2015 12:25
versionName config
View build.gradle
def versionMajor = 3
def versionMinor = 0
def versionPatch = 0
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
android {
defaultConfig {
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
tunjos /
Created June 23, 2015 02:35
Checks if device is charging
private boolean checkForPower() {
// It is very easy to subscribe to changes to the battery state, but you can get the current
// state by simply passing null in as your receiver. Nifty, isn't that?
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatus = this.registerReceiver(null, filter);
// There are currently three ways a device can be plugged in. We should check them all.
int chargePlug = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
boolean usbCharge = (chargePlug == BatteryManager.BATTERY_PLUGGED_USB);
tunjos /
Last active August 29, 2015 14:19
LogHelper Class
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
public class LogHelper {
private static final String LOG_TAG = MyConstants.APP_NAME;
public static void log(String message) {
Log.d(LOG_TAG, message);