Skip to content

Instantly share code, notes, and snippets.


Scott Alexander-Bown scottyab

View GitHub Profile
scottyab / ConvertLatLongToStaticMapUri
Created May 3, 2012
Quick and dirty util to convert a lat/long into a uri for google static maps.
View ConvertLatLongToStaticMapUri
* simple util to build the static google map url for the lat/long
* @param latitude
* @param longitude
* @return static google map url
public static Uri buildStaticGoogleMapUrlForAddress(String latitude, String longitude){
Builder builder = Uri.parse("").buildUpon();
builder.appendQueryParameter("center", latitude+","+longitude);
scottyab /
Created Apr 16, 2013
PagerAdapter X of Y. When using a view pager you can simply override the getPageTitle to create a page x of y text as seen in apps like gmail. This was used in a app to swipe through the RSS stories with Alternatively you could use something like
public class MyXofYPagerAdapter extends FragmentPagerAdapter {
private final ArrayList<RssItem> items;
public MyXofYPagerAdapter(FragmentManager fm,
ArrayList<RssItem> items) {
this.items = items;
scottyab / proguard-project.txt
Created Aug 23, 2013
Android Proguard config to remove all logging. Remember to enabled the -optimize progaurd config
View proguard-project.txt
#Remove Android logging code
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
public static java.lang.String getStackTraceString(java.lang.Throwable);
scottyab /
Last active Oct 7, 2020
Simple Android signature check. Please note: This was created in 2013, not actively maintained and may not be compatible with the latest Android versions. It's not particularly difficult for an attacker to decompile an .apk, find this tamper check, replace the APP_SIGNATURE with theirs and rebuild (or use method hooking to return true from `vali…
import android.content.Context;
public class TamperCheck {
//we store the hash of the signture for a little more protection
private static final String APP_SIGNATURE = "1038C0E34658923C4192E61B16846";
scottyab /
Last active Feb 6, 2017
Enforce correct initialisation of Random numbers - call this from Application.onCreate(). Basically copy of the code from the Some SecureRandom Thoughts blog post http://android- *
package com.scottyab.encryption;
* This software is provided 'as-is', without any express or implied
* warranty. In no event will Google be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, as long as the origin is not misrepresented.
public class Repository extends SQLiteOpenHelper {
private static final int VERSION = 1;
private static final String DATABASE_NAME = "data.sqlite";
private static File DATABASE_FILE;
// This is an indicator if we need to copy the
// database file.
private boolean mInvalidDatabaseFile = false;
private boolean mIsUpgraded = false;
private Context mContext;
scottyab /
Created Dec 17, 2013
Script to rename bouncycastle files to be spongycastle. From
# no further use for remaining crypto stuff
rm -Rf crypto
# Package rename org.bouncycastle to org.spongycastle
find -name bouncycastle | xargs rename s/bouncycastle/spongycastle/
find bc* -type f | xargs sed -i s/bouncycastle/spongycastle/g
scottyab /
Last active Aug 29, 2015
From article Spoke to Val and he clarified the Licensed under the Apache License, Version 2.0
#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
#Copyright 2013 Valentin Kalchev
#Date: 26/02/2013
#Target: Mac OS X Terminal + Android ADB + AAPT

Keybase proof

I hereby claim:

  • I am scottyab on github.
  • I am scottyab ( on keybase.
  • I have a public key whose fingerprint is 88AE 289F 03AE 3684 94BA B89F A056 9F94 AD10 76CD

To claim this, I am signing this object:

scottyab /
Last active Aug 29, 2015
Code from -- For the vast majority of applications, the requirement is to identify a particular installation, not a physical device. Fortunately, doing so is straightforward. There are many good reasons for avoiding the attempt to identify a particular device. Fo…
import java.util.UUID;
import android.content.Context;
You can’t perform that action at this time.