i devlop application of wakeup . problem that, application uses volume of calls , sms . , not of alarm.
public void onreceive(context context, intent intent) { uri uri = ringtonemanager.getactualdefaultringtoneuri(context,ringtonemanager.type_alarm); uri alert = ringtonemanager.getdefaulturi(ringtonemanager.type_alarm); ringtone = ringtonemanager.getringtone(context, alert); ringtone.play();
davidh's answer works ringtone.setstreamtype deprecated in api level 21. api level 21+ use:
ringtone.setaudioattributes(new audioattributes.builder().setusage(audioattributes.usage_alarm).build());
to support older android versions:
if (build.version.sdk_int >= build.version_codes.lollipop) { ringtone.setaudioattributes(new audioattributes.builder().setusage(audioattributes.usage_alarm).build()); } else { ringtone.setstreamtype(audiomanager.stream_alarm); }
Comments
Post a Comment