Skip to content

Instantly share code, notes, and snippets.

@tonykwok
tonykwok / ps.txt
Last active September 14, 2016 08:18
Android commands
adb shell ps | grep <PACKAGE.NAME>
adb shell cat /proc/<PID>/status
adb shell ps --abi
@tonykwok
tonykwok / Main.java
Last active May 4, 2016 01:24
Don't leave the previous camera preview hanging on the screen, that looks weird if the aspect ratio or scene changes.
// We need to do this with OpenGL ES (*not* Canvas -- the "software render" bits
// are sticky). We can't stay connected to the Surface after we're done because
// that will prevent the camera from attaching.
// @param surface should be either Surface or SurfaceTexture
public static void clear(object surface) {
try {
if (Log.IS_DEBUG) Log.logDebug(TAG, "clear() using OpenGL ES: E");
WindowSurface windowSurface = new WindowSurface(surface);
windowSurface.makeCurrent();
GLES20.glClearColor(0, 0, 0, 0);
import android.content.Context;
import android.os.Debug;
import java.io.File;
public class OomExceptionHandler implements Thread.UncaughtExceptionHandler {
private static final String FILENAME = "out-of-memory.hprof";
public static void install(Context context) {
Thread.UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
@tonykwok
tonykwok / CameraDumper.java
Last active May 4, 2016 01:26
A utility to check if camera device is being used by any application or not, if so, package name of the application will be returned.
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.List;