Skip to content

Instantly share code, notes, and snippets.

# if /proc/config.gz does not exist, load configs module
modprobe configs
zcat /proc/config.gz
# monitor property changed on the remote bt device
dbus-monitor --system "path=/org/bluez/hci0/dev_3C_28_6D_0A_99_FB,member=PropertiesChanged"
import ast
from ast import Assign, Name, Call, Store, Load, Str, Num, List, Add, BinOp
from ast import Subscript, Slice, Attribute, GeneratorExp, comprehension
from ast import Compare, Mult
import codegen
import random
import sys
def random_string(minlength, maxlength):
#define TAG "TAG"
#define LOG_VERBOSE(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
#define LOG_DEBUG(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
#define LOG_INFO(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
#define LOG_WARN(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
#define LOG_ERROR(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
#define LOG_FATAL(...) __android_log_print(ANDROID_LOG_FATAL, TAG, __VA_ARGS__)
@kenmasumitsu
kenmasumitsu / gist:dfed8d989d9df3586a0e
Created July 9, 2014 01:47
Save Bitmap as a file in SD card
void saveBitmapToSd(Bitmap mBitmap) {
try {
// sdcardフォルダを指定
File root = Environment.getExternalStorageDirectory();
// 日付でファイル名を作成 
Date mDate = new Date();
SimpleDateFormat fileName = new SimpleDateFormat("yyyyMMdd_HHmmss");
// 保存処理開始
@kenmasumitsu
kenmasumitsu / gist:bc0f5b87dd1e7c549f95
Last active August 29, 2015 14:03
Take a screenshot of View and whole screen
public Bitmap getViewBitmap(View view){
view.setDrawingCacheEnabled(true);
Bitmap cache = view.getDrawingCache();
if(cache == null){
return null;
}
Bitmap bitmap = Bitmap.createBitmap(cache);
view.setDrawingCacheEnabled(false);
return bitmap;
}
@kenmasumitsu
kenmasumitsu / gist:9341425
Last active August 29, 2015 13:56
Android: How to check service is running.
public static boolean isServiceRunning(Context context) {
ActivityManager manager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
Log.v(LOGTAG, "service name:" + service.service);
if (MyService.class.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}