根据Google提供的文档(http://developer.android.com/wear/notifications/remote-input.html),我正在玩Android Wear,但我陷入了可能遗漏某些东西的地方。你们能帮忙吗?这是代码。
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);
正如文档中所声明的那样,我的主要操作按钮未转换为"回复"应该如此。
答案 0 :(得分:0)
我修复了将活动添加到清单中的问题。一个诚实的错误。对于那些正在使用Android服装的人,请记住,您未在代码块中挂起的未添加到清单中的待处理活动不会使您的应用程序崩溃。堆栈跟踪中不会有“缺少类声明”。