android插入usb或充电震动

来源:互联网 发布:平板刷机软件 编辑:程序博客网 时间:2024/06/03 15:58

在NotificationManagerService

构造函数中添加

filter.addAction(Intent.ACTION_POWER_CONNECTED);

在广播接收器中添加处理函数

else if (action.equals(Intent.ACTION_POWER_CONNECTED)) {
                updateACNotification();
            }


private void updateACNotification() {  
        if (SystemProperties.getBoolean("hyst.t18.sp026",false)) {
            mVibrator.vibrate(200);
        }
    }


有的时候插入USB不震动,需要在

StorageNotification中的updateUsbMassStorageNotification方法中添加

mVibrator.vibrate(200);

在start中初始化mVibrator = (Vibrator)mContext.getSystemService(Context.VIBRATOR_SERVICE);

0 0
原创粉丝点击