Skip to content

Instantly share code, notes, and snippets.

View patrickhammond's full-sized avatar

Patrick Hammond patrickhammond

View GitHub Profile
import android.os.Parcel;
import android.os.Parcelable;
public class ParcelableHelper {
/**
* There is not always a guarantee that Parcelable values will be immediately written out and
* read back in. For data data that mutable (its own issue), this can be a problem. This is
* for the times when it would be great to have confidence that you will be working with a copy
* of that data.
@patrickhammond
patrickhammond / close_slide_enter.xml
Created March 25, 2015 16:31
Slide in and slide out animations.
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_shortAnimTime"
android:fromXDelta="-100%"
android:toXDelta="0" />
</set>
@patrickhammond
patrickhammond / readme.md
Last active September 14, 2018 14:25
Useful signing, verification, etc commands

Display the certificate used to sign the APK: keytool -list -printcert -jarfile app-release.apk

Display how each APK file is signed: jarsigner -verify -verbose -certs app-release.apk

Display certificate information: keytool -list -v -keystore yourkeystore -alias youralias

Display some of the info around how the APK presents itself: aapt d badging app-prod-release.apk

Decompile an existing APK: apktool d app-prod-release.apk (see: https://code.google.com/p/android-apktool)

@patrickhammond
patrickhammond / EspressoTestRule.java
Last active September 2, 2018 12:14
Hacking through Espresso issues...
import android.app.Activity;
import android.app.Instrumentation;
import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.support.test.InstrumentationRegistry;
@patrickhammond
patrickhammond / outline.markdown
Last active April 30, 2018 21:34
Getting Started with Android Wear Outline

Getting Started with Android Wear

Disclaimer

Details presented tonight are likely to change after Google I/O.

What is Android Wear and why should I care

  • New API to support wearable devices (currently only watches) coming to market soon.
  • Lots of wearable attention at Google I/O
  • Incredibly easy to make your apps work well on Android Wear devices
@patrickhammond
patrickhammond / screenrecord.sh
Last active April 30, 2018 21:32
Script to simplify screen recording with Android 4.4 and later devices. This takes care of setting the screenrecord flags, pulling files from the device, cleaning up after the recording, and optionally automatically opening the recording for you. Assumes only one connected device. Works for OSX but probably easy to make work with Linux (I believ…
#!/bin/bash
bitrate_flag=""
rotate_flag=""
open_when_done=0
OPTIND=1
while getopts "hron:" opt; do
case "$opt" in
h)
@patrickhammond
patrickhammond / YourApplication.java
Created February 10, 2014 13:54
Easy way to get rough screen level analytics in your app with very little work. API 14+
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import com.google.analytics.tracking.android.EasyTracker;
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
setupAnalytics();
package com.atomicrobot.app;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
public class ActivityFirstRunHelper {
@patrickhammond
patrickhammond / notes.markdown
Last active April 30, 2018 21:26
Android highlights, hints, helpers, etc.

Platform versions

  • 1.5 (3 - Cupcake)
  • 1.6 (4 - Donut)
  • 2.0 through 2.1 (5, 6, 7 - Eclair)
  • 2.2 (8 - Froyo)
  • 2.3.1 through 2.3.3 (9, 10 - Gingerbread)
  • 3.0 through 3.2 (11 - Honeycomb)
  • 4.0.0 (14 - Ice Cream Sandwich)
  • 4.0.3 (15 - Ice Cream Sandwich - MR1)
  • 4.1.2 (16 - Jelly Bean)
@patrickhammond
patrickhammond / cleanupInteliJFiles.sh
Created August 6, 2014 17:37
Remove all IntelliJ/Android Studio project files
#!/bin/sh
find . -name *.iml -print0 | xargs -0 rm
rm -rf .idea/