android插入usb或充电震动

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:39   1716   0

在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 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP