Skip to content

Instantly share code, notes, and snippets.

@twaddington
twaddington / gist:5862667
Created June 25, 2013 21:37
Samsung Galaxy S4 - Camera supported picture sizes
D/Simple (23737): 4128x3096
D/Simple (23737): 4128x2322
D/Simple (23737): 3264x2448
D/Simple (23737): 3264x1836
D/Simple (23737): 2048x1536
D/Simple (23737): 2048x1152
D/Simple (23737): 1280x720
D/Simple (23737): 640x480

MyProject/settings.gradle

include ':app', ':libraries:ActionBarSherlock:library'

MyProject/build.gradle

// The buildscript object bootstraps the Android build
buildscript {
    repositories {

mavenCentral()

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.3'
}
}
@twaddington
twaddington / android-notify-vibrate.md
Created April 10, 2013 23:04
Controlling the vibrate behavior of Android notifications.
    AudioManager audioManager =
            (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    switch (audioManager.getRingerMode()) {
        case AudioManager.RINGER_MODE_NORMAL:
            if (mVibrate) {
                defaults |= Notification.DEFAULT_VIBRATE;
            }
            defaults |= Notification.DEFAULT_SOUND;
 break;
@twaddington
twaddington / adb-tcpip.md
Last active December 16, 2015 00:49
Android wireless debugging.
$ adb tcpip 5555
$ adb connect <device-ip-address>:5555

# Reset for usb
$ adb usb

Nexus 4

  • D/Simple (13903): auto
  • D/Simple (13903): infinity
  • D/Simple (13903): normal
  • D/Simple (13903): macro
  • D/Simple (13903): continuous-picture
  • D/Simple (13903): continuous-video

Galaxy Nexus

/**
* Instances of this class can be used to safely retain references to
* <code>View</code> objects.
*
* <p>
* Prior to Android 4.0 storing a <code>View</code> as a tag with the
* {@link View#setTag(int, Object)} method could <a
* href="http://code.google.com/p/android/issues/detail?id=18273">result in
* memory leaks</a>. Instead, the {@link View#setTag(Object)} method should be
* used with a <code>ViewHolder</code> instance as the object.

Supported sizes

Camera.Parameters params = mCamera.getParameters();

Log.d(TAG, "Supported sizes:");
List<Camera.Size> sizes = params.getSupportedPictureSizes();
for (Camera.Size s : sizes) {
    Log.d(TAG, String.format("  %s x %s", s.width, s.height));
}
// We imply that we expect a JSON response by using the SFJsonRequestHandler...
Future f = client.getPath("/foo/bar", new SFJsonRequesthandler() {
@Override
public void onStart() {
// Pass
}
@Override
public void onFinish() {
// Pass
}
@twaddington
twaddington / TypefaceTextView.java
Last active March 31, 2020 15:48
An Android TextView with support for custom typefaces.
/*
* TypefaceTextView.java
* Simple
*
* Copyright 2012 Simple Finance Corporation (https://www.simple.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
*