StorageNotification继承于SystemUI,主要处理Storage事件,比如Storage插拔等。
在StorageNotfication的start函数,会去注册StorageEventListener。
@Override
public void start() {
mNotificationManager = mContext.getSystemService(NotificationManager.class);
mStorageManager = mContext.getSystemService(StorageManager.class);
mStorageManager.registerListener(mListener);
对于U盘或SD卡插拔事件,我们常用的是通过广播的方式去接收,具体可以参考:
http://blog.csdn.net/zhudaozhuan/article/details/7199799
StorageEventListener的实现如下:
private final StorageEventListener mListener = new StorageEventListener() {
@Override
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
onVolumeStateChangedInternal(vol);
}
@Override
public void onVolumeRecordChanged(VolumeR