通知操作按钮外观

时间:2012-07-26 11:59:20

标签: android notifications

如何使通知按钮按预期显示(如下图中的第二个通知)?

这是我的代码:

Notification.Builder nb = new Notification.Builder(mCtx);
    nb.setTicker("DATART");
    nb.setSmallIcon(R.drawable.ic_menu_info_details_select);
    nb.setContentText("DATART text");
    nb.setContentTitle(mCtx.getString(R.string.app_name));
    nb.setContentIntent(getClickIntent());
    nb.setAutoCancel(true);
    nb.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND);
    nb.setLights(LED, LEDON, LEDOFF);
    nb.addAction(android.R.drawable.ic_btn_speak_now, "Prihodit", PendingIntent.getActivity(mCtx, 0, new Intent(mCtx, AuctionProductDetail.class), 0));
    nb.addAction(android.R.drawable.ic_dialog_map, "Mapa", PendingIntent.getActivity(mCtx, 0, new Intent(mCtx, AuctionProductDetail.class), 0));
    return nb.build();

Notification

1 个答案:

答案 0 :(得分:2)

看起来我必须将android:targetSdkVersion设置为11或以上