相关疑难解决方法(0)

Android通知声音

我使用了较新的NotificationCompat构建器,但我无法收到通知以发出声音.它会振动并闪烁光线.android文档说要设置我已完成的样式:

  builder.setStyle(new NotificationCompat.InboxStyle());
Run Code Online (Sandbox Code Playgroud)

但没声音?

完整代码:

NotificationCompat.Builder builder =  
        new NotificationCompat.Builder(this)  
        .setSmallIcon(R.drawable.ic_launcher)  
        .setContentTitle("Notifications Example")  
        .setContentText("This is a test notification");  


Intent notificationIntent = new Intent(this, MenuScreen.class);  

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,   
        PendingIntent.FLAG_UPDATE_CURRENT);  

builder.setContentIntent(contentIntent);  
builder.setAutoCancel(true);
builder.setLights(Color.BLUE, 500, 500);
long[] pattern = {500,500,500,500,500,500,500,500,500};
builder.setVibrate(pattern);
builder.setStyle(new NotificationCompat.InboxStyle());
// Add as notification  
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);  
manager.notify(1, builder.build());  
Run Code Online (Sandbox Code Playgroud)

android android-notifications

146
推荐指数
11
解决办法
18万
查看次数

标签 统计

android ×1

android-notifications ×1