【notification】Android 中创建震动通知
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);Notification notification = new Notification();notification.vibrate = new long[]{0, 200, 100,
·
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” /> 权限。
更多推荐

所有评论(0)