Skip to content

Instantly share code, notes, and snippets.

@blundell
blundell / WatchFaceLifecycle-ExampleActivity.java
Last active August 29, 2015 14:03
Unofficial Base WatchFace Listener
public class ExampleActivity extends Activity implements WatchFaceLifecycle.Listener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_layout);
WatchFaceLifecycle.attach(this, savedInstanceState, this);
}
@Override
@falkorichter
falkorichter / git-remove-history
Created January 20, 2015 08:01
git-remove-history
#!/bin/bash
set -o errexit
# Author: David Underhill, Falko Richter
# Originally from http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
@handstandsam
handstandsam / ObjectifyGeocellQueryEngine.java
Created April 19, 2012 14:53
Geomodel Geocell Query Engine for Objectify
import java.util.List;
import java.util.StringTokenizer;
import com.beoui.geocell.GeocellQueryEngine;
import com.beoui.geocell.model.GeocellQuery;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.Query;
/**
* Objectify implementation for GeocellQueryEngine.
@ignasi
ignasi / db_getter.sh
Created January 30, 2014 11:43
Get database from an Android app (Android 4.3+)
#!/bin/bash
# Android 4.3+ changes app's internal directory permissions and you can not just pull your
# databases to your computer, so I did this as a workaround to extract my databases.
# I only use it for debug, use it under your responsability.
package=$1
db_name=$2
path="/data/data/$package/"
@polbins
polbins / README.md
Last active September 6, 2019 11:08
Android Response Caching using Retrofit 1.9 + OkHttp 2.2

Android REST Controller with Cache-Control

Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0

@JakeWharton
JakeWharton / README.md
Last active January 8, 2020 02:13
A special activity which facilitates restarting your application process.
@stefanhoth
stefanhoth / build.gradle
Created June 11, 2014 06:56
AndroidDev / gradle: How to rename your output apk during build time to include details like the version.
android {
// .. set up build flavors etc here
//instead of "app-release.apk" this method will rewrite the name to
// "MyCoolCompany-MyGreatProduct-v<defaultConfig.versionName>-RELEASE.apk which is much better suited for archiving and overall handling
// To restore the default behavior just delete the whole block below
applicationVariants.all { variant ->
def apk = variant.outputFile;
@jaredrummler
jaredrummler / MenuTint.java
Last active April 13, 2022 03:58
Helper class to set the color and transparency for menu icons in an ActionBar or Toolbar.
/*
* Copyright (C) 2015. Jared Rummler <jared.rummler@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@JakeWharton
JakeWharton / gist:f50f3b4d87e57d8e96e9
Created February 7, 2015 01:59
Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your `src/debug/` code and run it when the application or main activity starts. Apache 2.
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =
@artem-zinnatullin
artem-zinnatullin / MyApp.java
Last active January 15, 2023 13:04
If you need to set one font for all TextViews in android application you can use this solution. It will override ALL TextView's typefaces, includes action bar and other standard components, but EditText's password font won't be overriden.
public class MyApp extends Application {
@Override
public void onCreate() {
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
}
}