Skip to content

Instantly share code, notes, and snippets.

@bdiegel
bdiegel / android_bmgr_help
Created May 16, 2015 15:20
Android bmgr tool
// ensure backup manager is enabled (emulator)
adb shell bmgr enable true
// request a backup from manager
adb shell bmgr backup your.package.name
// force backup manager to run queued requests
adb shell bmgr run
// uninstall app
@bdiegel
bdiegel / Android_Tools
Last active August 29, 2015 14:17
Android Tools and Resources
// Assets and Icons
http://romannurik.github.io/AndroidAssetStudio/
https://github.com/google/material-design-icons
http://developer.android.com/design/downloads/index.html
// Material Design
http://www.materialpalette.com/
http://www.google.com/design/spec/material-design/introduction.html
@bdiegel
bdiegel / Android_Parcelable
Created March 14, 2015 13:48
Android Parcelables with Intents
/**
* Creating and passing a Parcelable with an Intent
*/
// Creating an instance of Student class with user input data
Student student = new Student(mNameTV.getText().toString(),
Integer.parseInt(mAgeTV.getText().toString()),
mAddressTV.getText().toString(),
mCourseTV.getText().toString());
// Creating an intent to open the activity StudentViewActivity
@bdiegel
bdiegel / android_toolbar_home.java
Created February 26, 2015 22:03
Android Toolbar Home Button
# To add navigation back to the main activity using the
# Toolbar (material design), we do three things:
# 1. Declare the parent activity in the AndroidManifest.xml
#
# <activity android:name=".MySubActivity" android:label="@string/title_sub_activity" >
# <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity" />
# </activity>
# 2. Configure the Toolbar in MySubActivity:
@bdiegel
bdiegel / android_hierarchyviewer
Created February 17, 2015 19:13
Android Hierarchy Viewer
# Hierarchy Viewer only works by default with phones running a developer version of the Android OS.
#
# 1. Phone running Jellybean or higher: add the environment variable: ANDROID_HVPROTO=ddm
# 2. You can run Hierarchy Viewer on an emulated phone.
# 3. Use the ViewServer library for pre Jellybean phone
# https://github.com/romainguy/ViewServer
# set this environment variable
$ export ANDROID_HVPROTO=ddm;
@bdiegel
bdiegel / couchbase_change_password.sh
Created February 14, 2015 23:47
Change Couchbase password
./couchbase-cli cluster-init -c 127.0.0.1:8091 --user=[CURRENT_USERNAME] --password=[CURRENT_PASSWORD] --cluster-init-username=[NEW_USERNAME] --cluster-init-password=[NEW_PASSWORD]
@bdiegel
bdiegel / py_venv_couchbase
Last active August 29, 2015 14:14
Python Couchbase Virtualenv
workon venv
pip install git+git://github.com/couchbase/[email protected]
pip install flask
pip install flask-restful
@bdiegel
bdiegel / couchbase_bulk_insert.sh
Last active August 29, 2015 14:14
couchbase_bulk_insert
# example of inserting documents from zip file into a couchbase bucket
sudo /opt/couchbase/bin/cbdocloader -u <username> -p <password> -n localhost:8091 -b <bucket> -s 100 ~path/to/data.zip
@bdiegel
bdiegel / android_combined_search_suggestions.java
Last active March 27, 2017 10:41
Android combined recent and custom search suggestions
/**
* It's possible to combine recent and custom search suggestions. One way is to
* write a custom provider that extends SearchRecentSuggestionsProvider. If the
* custom provider has the same columns as SearchRecentSuggestionsProvider
* then the cursors can be easily 'merged'.
*
* In the .query() method of custom search provider, return the combined results:
*/
Cursor recentCursor = super.query(uri, projection, sel, selArgs, sortOrder);
Cursor[] cursors = new Cursor[] { recentCursor, customCursor};
@bdiegel
bdiegel / libGL.so error
Created October 5, 2014 17:03
Android emulator libGL error
Error running Android emulator on Linux:
libGL.so cannot open shared object file
$ sudo apt-get install libgl1-mesa-dev