Android穿戴远程语音输入到主动作意图



我正在玩Android Wear根据谷歌提供的文档(http://developer.android.com/wear/notifications/remote-input.html),但我卡住了一部分,我可能错过了一些东西。你们能帮忙吗?代码如下:

Intent viewIntent = new Intent(this, ActionActivity.class);
        viewIntent.putExtra(getString(R.string.extraStringTag), extraString);
PendingIntent viewPendingIntent =
        PendingIntent.getActivity(this, 0, viewIntent, 0);
Intent mapIntent = new Intent(Intent.ACTION_VIEW);
Uri geoUri = Uri.parse("geo:0,0?q=" + Uri.encode(location));
mapIntent.setData(geoUri);
PendingIntent mapPendingIntent =
        PendingIntent.getActivity(this, 0, mapIntent, 0);
BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
bigStyle.bigText(eventDescription);
String[] replyChoices = getResources().getStringArray(R.array.reply_choices);
RemoteInput remoteInput = new RemoteInput.Builder(getString(R.string.extraStringTag))
        .setLabel(replyTitle)
        .setChoices(replyChoices)
        .build();
NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.questionblock)
        .setLargeIcon(BitmapFactory.decodeResource(
                getResources(), R.drawable.mariopagebg))
        .setStyle(bigStyle)
        .setContentTitle(eventTitle)
        .setContentText(eventDescription)
        .setContentIntent(viewPendingIntent)
        .addAction(R.drawable.mariomap,
                mapString, mapPendingIntent);
Notification notification = new WearableNotifications.Builder(notificationBuilder)
        .addRemoteInputForContentIntent(remoteInput)
        .build();
// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
        NotificationManagerCompat.from(this);
// Build the notification and issues it with notification manager.
notificationManager.notify(notificationId, notification);

正如文档中声明的那样,我的主要动作按钮没有被转换为"回复",因为它应该是

我修复了将活动添加到清单的问题。一个无心之过。对于那些正在玩android wear的人,请记住,代码块中未添加到清单中的未决活动不会使应用程序崩溃。在你的堆栈跟踪中不会有"丢失的类声明"。

相关内容

  • 没有找到相关文章

最新更新