Android 应用程序通知中断Pandora卷

Android 应用程序通知中断Pandora卷,android,audio,notifications,Android,Audio,Notifications,希望有人能帮我们解决一个奇怪的错误:当我们的Android应用程序发布一个状态栏通知,用户正在收听潘多拉时,通知的音量会下降(正如预期的那样),但直到下一首歌才恢复 这似乎不会发生在Pandora以外的流媒体应用程序中,也不会发生在我们以外的应用程序中——尽管据我所知,我们使用通知API是标准的。它也仅限于某些设备:它不会发生在我们的Nexus4或DroidRazr M上,但我们可以在运行4.2.2的Galaxy Nexus上始终如一地复制它 知道发生了什么吗 编辑 根据要求,我们的广播接收器代

希望有人能帮我们解决一个奇怪的错误:当我们的Android应用程序发布一个状态栏通知,用户正在收听潘多拉时,通知的音量会下降(正如预期的那样),但直到下一首歌才恢复

这似乎不会发生在Pandora以外的流媒体应用程序中,也不会发生在我们以外的应用程序中——尽管据我所知,我们使用通知API是标准的。它也仅限于某些设备:它不会发生在我们的Nexus4或DroidRazr M上,但我们可以在运行4.2.2的Galaxy Nexus上始终如一地复制它

知道发生了什么吗

编辑 根据要求,我们的广播接收器代码的一些信息。最初,它通过一个ContentProvider对我们的DB执行一系列操作,以获取要在通知中显示的信息。完成后:

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
        .setSmallIcon(R.drawable.ic_notification_new_message)
        .setTicker(Html.fromHtml("<strong>" + senders[0] + "</strong> " + summaries[0]))
        .setContentInfo((messageCount > 1) ? Integer.toString(messageCount) : "").setAutoCancel(true); 

// Notification sound and vibration
if (prefs.getBoolean(PREF_SOUND, true)) {
    setupSound(builder);
}

// Blinky light
if (prefs.getBoolean(PREF_BLINK, true)) {
    setupLight(builder, LIGHT_COLOR);
}

Intent resultIntent;
TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);

if (senders.length > 1) {
    String contentTitle = messageCount + " new messages";
    builder.setContentTitle(contentTitle);
    builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher));

    NotificationCompat.InboxStyle bigStyle = new NotificationCompat.InboxStyle();
    bigStyle.setBigContentTitle(contentTitle);

    HashSet<String> uniqueSenders = new HashSet<String>(senders.length);
    for (i = 0; i < senders.length; i++) {
        bigStyle.addLine(Html.fromHtml("<strong>" + senders[i] + "</strong> " + summaries[i]));
        uniqueSenders.add(senders[i]);
    }
    builder.setContentText(TextUtils.join(", ", uniqueSenders));
    builder.setStyle(bigStyle);

    resultIntent = new Intent(App.getContext(), ChatListActivity.class);
} else {
    builder.setContentTitle("Message from " + senders[0]);
    setLargeImage(context, lastCorrespondents, builder);

    builder.setContentText(summaries[0]);

    // Intent + back stack
    resultIntent = new Intent(context, ChatActivity.class);
    resultIntent.putExtra(MessageDbContract.KEY_CORRESPONDENTS, lastCorrespondents);
    taskStackBuilder.addParentStack(ChatActivity.class);
}

resultIntent.putExtra(Constants.INTENT_KEY_CALLER, getClass().getSimpleName());

// Finish configuring action
invokeNotificationManager(context, builder, resultIntent, taskStackBuilder, NOTIFICATION_ID_NEW_MESSAGES);

您的BroadcastReceiver启动了什么代码?根据请求添加了代码。
private void setLargeImage(Context context, String lastCorrespondents, NotificationCompat.Builder builder) {
    // Set large image
    try {
        Uri imageUri = Util.getThumbnailUriForCorrespondents(context, lastCorrespondents);
        Bitmap largeImage = MediaStore.Images.Media.getBitmap(context.getContentResolver(), imageUri);
        builder.setLargeIcon(largeImage);
    } catch (IOException e) {
        Util.log(this, "Encountered IOException when setting large icon for new message notification.");
    }
}

private void setupLight(NotificationCompat.Builder builder, int lightColor) {
    builder.setLights(lightColor, LIGHT_ON_DURATION, LIGHT_OFF_DURATION);
}

private void setupSound(NotificationCompat.Builder builder) {
    Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    builder.setSound(uri);
    builder.setVibrate(VIBRATION_PATTERN);
}

private void invokeNotificationManager(Context context, NotificationCompat.Builder builder, Intent resultIntent,
        TaskStackBuilder taskStackBuilder, int notificationId) {
    taskStackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = taskStackBuilder.getPendingIntent(0,
            PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);

    // Get notification manager, create notification, and notify.
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(App.NOTIFICATION_NEW_MESSAGE, notificationId, builder.build());
}