Skip to content

Instantly share code, notes, and snippets.

package com.xinghui.notificationlistenerservicedemo;
import android.app.ActivityManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.os.Process;
@zysyyz
zysyyz / gist:adb4a5be69f786c631350f69a5a95d5f
Created June 6, 2018 06:47 — forked from strazzere/gist:506a592b44c9d228d697
Attaching to fast loading JNI/native code from an Android app without debugging the Dalvik code
The original issue was that some applications (ex. packers) launch the JNI/native code too fast for a person
to attach an IDA Pro instance to the process. The original solution was wrapping the jni code with your own
"surrogate" application so you could load it slower.
New process is to launch the Android/Dalvik activity with the debugger flag;
# adb shell am start -D com.play.goo_w/com.android.netservice.MainActivity
Which will cause the "Waiting for debugger..." mode to start. This starts the process, allowing you to
attach IDA Pro to the process for the native code.
@zysyyz
zysyyz / release-android-debuggable.md
Created January 24, 2018 14:27 — forked from nstarke/release-android-debuggable.md
How to make a Release Android App debuggable

How to make a Release Android App debuggable

Let's say you want to access the application shared preferences in /data/data/com.mypackage.
You could try to run adb shell and then run-as com.mypackage ( or adb shell run-as com.mypackge ls /data/data/com.mypackage/shared_prefs), but on a production release app downloaded from an app store you're most likely to see:

run-as: Package 'com.mypackage' is not debuggable
// iOS ロックスクリーン Notification
#define NotifName_LockComplete @"com.apple.springboard.lockcomplete"
#define NotifName_LockState @"com.apple.springboard.lockstate"
//call back
static void lockStatusChanged(CFNotificationCenterRef center, void *observer, CFStringRef name_cf, const void *object, CFDictionaryRef userInfo){
NSString *name = (__bridge NSString*)name_cf;
if ([name isEqualToString:NotifName_LockComplete]) {

原文地址

上一篇教程里,你学到了如何创建一个可复用的按钮控件。然而,对于开发者如何简单方便地来复用的话效果还不是非常明显。

一种共享它的方式就是直接提供源码文件。然而,这不是特别优雅。有可能你不想共享代码的实现细节。此外,开发者可能不想看见所有的东西,因为它们只是想继承一部分代码到自己的代码库里。

另一种方式是把你的代码编译成静态库来让开发者添加到他们的项目中去。然而这要求你来提供公共头文件,这样显得非常的笨拙。

你需要有一种简洁的方式来编译你的代码,并且它还要方便的共享和在多个项目间复用。你需要用什么方式来打包静态库并且它的头文件在一个文件里,然后只需要把这个文件添加到工程里就能立即开始使用。

@zysyyz
zysyyz / XcodeColor.pch
Created February 23, 2016 13:22 — forked from jkyin/XcodeColor.pch
格式化控制台输出颜色
/*
* 如何应用色彩格式化你的日志语句:
*
* 设置前景色:
* 插入 ESCAPE 到你的字符串,紧跟着 "fg124,12,255;" 这里表示 r=124, g=12, b=255。
*
* 设置背景色:
* 插入 ESCAPE 到你的字符串,紧跟着 "fg124,12,255;" 这里表示 r=12, g=24, b=36。
*
* 重置前景色(恢复为默认值):
@zysyyz
zysyyz / byte-sizetuts.md
Created November 21, 2015 08:28 — forked from honkskillet/byte-sizetuts.md
A series of golang tutorials with youtube videos.