0

向けのアプリを開発していAndroid Autoます。このようなマップ通知を送信したかったのです(大きなビューはまだ実装されていません)下の画像。

以下のコードで試してみました。しかし、マップ ナビゲーション通知の送信に失敗しました。

private void sendNotificationForConversation(Conversation conversation) {
    // A pending Intent for reads
    double latitude = 31.249351;
    double longitude = 121.45905;
    Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri
            .parse("http://maps.google.com/maps?saddr="
                    + latitude + ","
                    + longitude + "&daddr="
                    + 31.186371 + "," + 121.489885));

    notificationManager = (NotificationManager) getApplicationContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(R.drawable.notification_icon, "Kohls store ahead", 1000);
    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.activity_kcc);
    contentView.setTextViewText(R.id.hello, "This is the KCC layout");
    notification.contentView = contentView;

    PendingIntent readPendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    notification.contentIntent = readPendingIntent;

    notification.flags |= Notification.FLAG_AUTO_CANCEL; // clear the notification
    notification.defaults |= Notification.DEFAULT_LIGHTS; // LED
    notification.defaults |= Notification.DEFAULT_VIBRATE; //Vibration
    notification.defaults |= Notification.DEFAULT_SOUND; // Sound

    // Build a RemoteInput for receiving voice input in a Car Notification
    RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
            .setLabel(getApplicationContext().getString(R.string.notification_reply))
            .build();

    // Building a Pending Intent for the reply action to trigger
    PendingIntent replyIntent = PendingIntent.getBroadcast(getApplicationContext(),
            conversation.getConversationId(),
            getMessageReplyIntent(conversation.getConversationId()),
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Create the UnreadConversation and populate it with the participant name,
    // read and reply intents.
    NotificationCompat.CarExtender.UnreadConversation.Builder unreadConvBuilder =
            new NotificationCompat.CarExtender.UnreadConversation.Builder(conversation.getParticipantName())
                    .setLatestTimestamp(conversation.getTimestamp())
                    .setReadPendingIntent(readPendingIntent)
                    .setReplyAction(replyIntent, remoteInput);


    NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext())
            .setContent(contentView)
            .setContentIntent(readPendingIntent)
            .extend(new NotificationCompat.CarExtender()
                    .setUnreadConversation(unreadConvBuilder.build()));


    MessageLogger.logMessage(getApplicationContext(), "Sending notification "
            + conversation.getConversationId() + " conversation: " + conversation);

    notificationManager.notify(conversation.getConversationId(), builder.build());
}

これにより、シミュレーターで空の通知が表示され、ステータスバーには何も表示されません。この通知をクリックした後、Android auto car デバイスにナビゲート マップを表示したいと考えています。どうすればこれを修正できますか?

前もって感謝します!

4

1 に答える 1