Skip to content

Instantly share code, notes, and snippets.

@li2
li2 / SdcardService.java
Last active March 20, 2018 11:59
Auto run a shell script when SDCard is plugged in android device. 实现方式:启动一个 service,由 service 动态注册监听 sdcard 插拔事件的 receiver,当接收到系统发出的插拔事件的 broadcast 后,执行相应的操作。#tags: android-service
public class SDcardService extends Service {
@Override
public IBinder onBind(Intent intent) {
// Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onCreate() {
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);
@li2
li2 / HelloGist.md
Last active May 6, 2018 11:48
First gist note test #tags: git

This a my first gist note.

printf("Hello world.")