Skip to content

Instantly share code, notes, and snippets.

@shaobin0604
shaobin0604 / INotificationManager.aidl
Last active August 29, 2015 14:14
INotificationManager.aidl
/* //device/java/android/android/app/INotificationManager.aidl
**
** Copyright 2007, The Android Open Source Project
**
** 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
**
** http://www.apache.org/licenses/LICENSE-2.0
**
@shaobin0604
shaobin0604 / BrowserProvider2.java
Created December 7, 2014 18:08
ContentProviders in Browser
/*
* Copyright (C) 2010 he Android Open Source Project
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@shaobin0604
shaobin0604 / GetUnicode.java
Created September 17, 2014 06:59
GetUnicode.java
static String getUnicode(String s) {
try {
StringBuffer out = new StringBuffer("");
byte[] bytes = s.getBytes("unicode");
for (int i = 0; i < bytes.length - 1; i += 2) {
out.append("\\u");
String str = Integer.toHexString(bytes[i + 1] & 0xff);
for (int j = str.length(); j < 2; j++) {
out.append("0");
@shaobin0604
shaobin0604 / TransportControlViewICS.java
Created September 14, 2014 03:37
TransportControlView
/*
* Copyright (C) 2011 The Android Open Source Project
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
android.applicationVariants.all { variant ->
println "*********" + variant.description + "**********";
def variants = variant.baseName.split("-");
def apkName = "ricebook-";
apkName += variants[0];
apkName += "-v" + android.defaultConfig.versionName;
if (!variant.zipAlign) {
apkName += "-unaligned";
}
if (variant.buildType.name == "release") {
public static boolean isNotificationAccessibilityServiceEnabled() {
AccessibilityManager am = (AccessibilityManager) AppContext.getInstance().getSystemService(
Context.ACCESSIBILITY_SERVICE);
List<AccessibilityServiceInfo> list = am
.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
StringBuilder sb = new StringBuilder();
for (AccessibilityServiceInfo info : list) {
sb.append(info.getId());
sb.append(", ");
}
#!/bin/bash
# This is a wrapper for adb. If there are multiple devices / emulators, this script will prompt for which device to use
# Then it'll pass whatever commands to that specific device or emulator.
# Run adb devices once, in event adb hasn't been started yet
BLAH=$(adb devices)
# Grab the IDs of all the connected devices / emulators
IDS=($(adb devices | sed '1,1d' | sed '$d' | cut -f 1 | sort))
@shaobin0604
shaobin0604 / market_address.rb
Created April 24, 2014 16:27
market address redirect, market 可以识别 campaign,但 twitter/facebook 不能识别为链接
require 'webrick'
#
# serve page at http://192.241.188.164:8899/anything
#
class Simple < WEBrick::HTTPServlet::AbstractServlet
def do_GET request, response
response.status = 301
response['Content-Type'] = 'text/html; charset=UTF-8'
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
</style>
</resources>
@shaobin0604
shaobin0604 / 0_reuse_code.js
Created March 28, 2014 05:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console