Skip to content

Instantly share code, notes, and snippets.

View patrickhammond's full-sized avatar

Patrick Hammond patrickhammond

View GitHub Profile
@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)
/**
* Created by Bill on 7/28/14.
*/
public class LearningApplication extends Application {
private static final String TAG = QuickeyLearningApplication.class.getSimpleName();
@Override
public void onCreate() {
super.onCreate();
@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 / 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/
@patrickhammond
patrickhammond / CustomView.java
Created August 12, 2014 18:59
Custom views tricks
public Class CustomView {
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
// Makes the developer tools happy when previewing stuff
if (isInEditMode()) {
return;
}
}
}
@patrickhammond
patrickhammond / README.md
Last active April 30, 2018 21:24
Faster way to include stripped down Google Mobile Services in your application as a workaround to the 64k dex method limit problem that GMS frequently introduces. See README.md for details.

Context

I was previously using https://gist.github.com/dmarcato/d7c91b94214acd936e42 to strip down Google Mobiele Services, but the build times for my project in Android Studio consistently exceeded 75 seconds; this solution is much less dynamic (and even a little ugly) but keeps my build times less than 15s.

Assumptions

  • Your app module has a directory named aars that will work as a project specific Maven repository; this directory should be placed under version control.
  • Maven (mvn) is installed and available on your path when running this script.

Usage

@patrickhammond
patrickhammond / ParcelableHelper.java
Last active April 20, 2021 02:22
A Parcelable is not always immediately deep copied; this forces an immediate deep copy into a new Parcelable instance.
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 / MyActivity.java
Last active August 29, 2015 14:05
Lambdas on Android...its a brave new world. See: https://github.com/evant/gradle-retrolambda
public class MyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
// Old school
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
@Override
@patrickhammond
patrickhammond / DevicePhoneNumber.java
Created September 25, 2014 19:30
User and device info helper code
public class DevicePhoneNumber {
public final String phoneNumber;
public DevicePhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
@Override
public String toString() {
return "DevicePhoneNumber{" +