如何在通知中设置振动和声音

时间:2017-04-20 14:39:37

标签: android notifications

{{1}}

2 个答案:

答案 0 :(得分:0)

这些是一些虚拟代码,希望这对你有帮助。

private static NotificationCompat.Builder buildNotificationCommon(Context _context,.....){

NotificationCompat.Builder builder = new NotificationCompat.Builder(_context).setWhen(System.currentTimeMillis()).......;
 //Vibration
    builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });

 //LED
    builder.setLights(Color.RED, 3000, 3000);

 //Ton
    builder.setSound(Uri.parse("uri://sadfasdfasdf.mp3"));

return builder;

}

答案 1 :(得分:0)

可能对你有所帮助

 NotificationCompat.Builder builder = new      NotificationCompat.Builder(_context).setWhen(System.currentTimeMillis()).......;
 //Vibration      
builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });

//LED        
builder.setLights(Color.RED, 3000, 3000);

//Ton
builder.setSound(Uri.parse("uri://sadfasdfasdf.mp3"));

return builder;