NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.vibrate = new long[]{0, 200, 100, 200, 100, 200};    // 数组是以毫秒为单位的暂停、震动、暂停……时间
notificationManager.notify(R.string.app_name, notification);

说明:这时不会生成状态栏通知。会报权限异常,需要注意的是,要在 manifest 中添加 <uses-permission android:name=”android.permission.VIBRATE” /> 权限。
Logo

电商企业物流数字化转型必备!快递鸟 API 接口,72 小时快速完成物流系统集成。全流程实战1V1指导,营造开放的API技术生态圈。

更多推荐