Skip to content

Instantly share code, notes, and snippets.

@aprock
aprock / gist:2037883
Created March 14, 2012 17:00
manually serialize/deserialize android bundle
private String serializeBundle(final Bundle bundle) {
String base64 = null;
final Parcel parcel = Parcel.obtain();
try {
parcel.writeBundle(bundle);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final GZIPOutputStream zos = new GZIPOutputStream(new BufferedOutputStream(bos));
zos.write(parcel.marshall());
zos.close();
base64 = Base64.encodeToString(bos.toByteArray(), 0);
@christopherperry
christopherperry / adb+
Created July 30, 2012 16:12
A bash script that let's you issue adb commands to multiple devices at once
#!/bin/bash
# Script adb+
# Usage
# You can run any command adb provides on all your currently connected devices
# ./adb+ <command> is the equivalent of ./adb -s <serial number> <command>
#
# Examples
# ./adb+ version
# ./adb+ install apidemo.apk
# ./adb+ uninstall com.example.android.apis
@christopherperry
christopherperry / CheckableLinearLayout
Created September 18, 2012 22:43
A LinearLayout that implements the Checkable interface, allowing a LinearLayout to be put into a checked state.
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Checkable;
import android.widget.LinearLayout;
@ferdhie
ferdhie / ExifRotate.java
Created September 26, 2012 14:16
Auto rotate image using exif data
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.EncodedImage;
@felipecsl
felipecsl / restart coreaudio daemon
Last active May 17, 2024 22:17
Restart Mac OS X coreaudio daemon. Useful if you cannot change the audio output device to Airplay.
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`
# or...
sudo killall coreaudiod
@pwittchen
pwittchen / ContactsProvider.java
Last active April 17, 2016 06:19
ContactsProvider class
public class ContactsProvider {
private Uri QUERY_URI = ContactsContract.Contacts.CONTENT_URI;
private String CONTACT_ID = ContactsContract.Contacts._ID;
private String DISPLAY_NAME = ContactsContract.Contacts.DISPLAY_NAME;
private Uri EMAIL_CONTENT_URI = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
private String EMAIL_CONTACT_ID = ContactsContract.CommonDataKinds.Email.CONTACT_ID;
private String EMAIL_DATA = ContactsContract.CommonDataKinds.Email.DATA;
private String HAS_PHONE_NUMBER = ContactsContract.Contacts.HAS_PHONE_NUMBER;
private String PHONE_NUMBER = ContactsContract.CommonDataKinds.Phone.NUMBER;
@akshaydashrath
akshaydashrath / gist:10119943
Last active March 25, 2024 13:54
Signing HttpUrlConnection using OkHttpClient and Retrofit
@Override
public Response execute(Request request) throws IOException {
HttpsURLConnection connection = (HttpsURLConnection) super.openConnection(request);
try {
prepareRequest(connection, request);
} catch (Exception e) {
e.printStackTrace();
}
return readResponse(connection);
}
@burgalon
burgalon / AccountAuthenticator.java
Last active July 15, 2023 08:29
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
@martarodriguezm
martarodriguezm / Google Play Api - Apk Upload.md
Last active October 28, 2021 00:15
This python script uploads an apk file into Google Play Store using Android Play Publisher API

In Google Developer Console inside your app project, on the Credentials section, you must create a new "Service Account" "Client ID", if you have not already. And download the p12 file. You need the service account key file, generated in the Google APIs Console into the same directory and rename it to key.p12.

On Google Play Developer Console you have to give permissions to "YOUR_SERVICE_ACCOUNT_EMAIL@developer.gserviceaccount.com" for uploading apks.

Installation

Download Google APIs Client Library for Python (google-api-python-client): https://code.google.com/p/google-api-python-client/ or use pip:

$ pip install google-api-python-client

In Google Developer Console inside your app project, on the Credentials section, you must create a new "Service Account" "Client ID", if you have not already. And download the JSON file.

On Google Play Developer Console you have to give permissions to "YOUR_SERVICE_ACCOUNT_EMAIL@developer.gserviceaccount.com" for uploading apks.

Installation

Download Google APIs Client Library for Python (google-api-python-client): https://code.google.com/p/google-api-python-client/ or use pip:

  $ pip install google-api-python-client