NotificationCompat.Builder nb = new NotificationCompat.Builder(this); nb.setContentTitle("Title"); nb.setContentText("message"); nb.setSmallicon(getResources().getIDentifIEr("drawable/alert",null,packagename)); nb.setWhen(System.currentTimeMillis()); nb.setautoCancel(true); nb.setTicker("message"); final Uri ringtone = Uri.parse(PreferenceManager.getDefaultSharedPreferences(this).getString("ringtone",getString(R.string.settings_default_ringtone))); nb.setDefaults(Notification.DEFAulT_VIBRATE); nb.setSound(ringtone); nb.setDefaults(Notification.DEFAulT_liGHTS); notificationmanager nm = (notificationmanager)getSystemService(Context.NOTIFICATION_SERVICE); final Intent notificationIntent = new Intent(this,Main.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_top | Intent.FLAG_ACTIVITY_NEW_TASK); final PendingIntent contentIntent = PendingIntent.getActivity(this,notificationIntent,0); nb.setContentIntent(contentIntent); Notification notification = nb.getNotification(); nm.notify(0,notification);解决方法 我自己测试了一下,振动/铃声即使在更新时也会启动.
更新:只是更新,如果您使用NotificationCompat.Builder或Notification.Builder,您可以将setonlyAlertOnce设置为仅响铃铃声/振动一次.
总结以上是内存溢出为你收集整理的android – 更新通知振动/铃声全部内容,希望文章能够帮你解决android – 更新通知振动/铃声所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)