java - Notification won't Vibrate -


i'm writing simple notification demo in android studio there's button in main activity , when click it, notification comes leads activity on click. setvibrate on notification obj there's no vibrate. not sure if pattern off or not.

notificationcompat.builder notification; private static final int id = 123;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      notification = new notificationcompat.builder(this);     notification.setautocancel(true);  }   public void notificationmethod(view v){      notification.setsmallicon(r.mipmap.ic_launcher);     notification.setticker("this ticker");     notification.setwhen(system.currenttimemillis());     notification.setcontenttitle("this title");     notification.setcontenttext("this text");     notification.setvibrate(new long[]{1000,1000,1000,1000,1000} );       intent intent = new intent(this, notificationactivity.class);     pendingintent pintent = pendingintent.getactivity(this, 0, intent, pendingintent.flag_cancel_current);     notification.setcontentintent(pintent);      notificationmanager nm = (notificationmanager) getsystemservice(notification_service);     nm.notify(id, notification.build());  } 

make sure have vibrate permission in manifest.

<uses-permission android:name="android.permission.vibrate" /> 

side-note: on android m, not have request @ runtime, normal permission.

you can read more normal permissions here.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -