android - Is possible to update the sound of current notification? -


i have helper class helps me building , showing 1 notification 2 states.

in constructor i'm initializing notificationcompat.builder common settings both states. in 1 method (shownotificationcircle()) i'm showing notification circle icon, texts , 'click' sound.

in method (shownotificationrect()), i'm showing notification icon, texts , sound when notification appears still same sound no matter method used.

this constructor:

public notifhelper(context context) {       clicksounduri = uri.parse("android.resource://" + context.getpackagename() + "/" + r.raw.click_sound);       bulbsounduri = uri.parse("android.resource://" + context.getpackagename() + "/" + r.raw.bulb_sound);       builder = new notificationcompat.builder(context);       builder.setcontenttitle(context.getstring(r.string.some_text_1))                .setcolor(context.getresources().getcolor(r.color.white))                .setautocancel(false)                .setshowwhen(false)                .setongoing(true)                .setdefaults(notification.default_vibrate | notification.default_lights); } 

this method circle state:

public void shownotificationcircle() {         builder.setcontentintent(pendingintent);         builder.setsmallicon(r.mipmap.ic_circle);         builder.setpriority(notification.priority_default);         builder.setsound(clicksounduri);         notification = builder.build();         notificationmanager manager = (notificationmanager) context.getsystemservice(context.notification_service);         manager.notify(notification_id, notification); } 

and second method:

 public void shownotificationrect() {     builder.setcontentintent(pendinintent2);     builder.setsmallicon(r.mipmap.ic_rect);     builder.setpriority(notification.priority_min);     builder.setsound(bulbsounduri);     notification = builder.build();     notificationmanager manager = (notificationmanager) context.getsystemservice(context.notification_service);     manager.notify(notification_id, notification);  } 

i have no idea why played 'clicksounduri' instead of 'bulbsounduri' when invoked shownotificationrect().


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -