我有以下代码,但它没有打开拨号器。
Intent callIntent = new Intent(Intent.ACTION_CALL);
String uri = "tel: " + requestDetail.driver.phone_number.trim();
callIntent.setData(Uri.parse(uri));
PendingIntent callPendingIntent =
PendingIntent.getActivity(context, 0, callIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.uber_badge)
.setVibrate(new long[]{500, 300, 500, 300, 500, 300, 500, 300})
.setContentTitle(title)
.setAutoCancel(false)
.setContentText("Driver Accepted\nETA: " + requestDetail.eta + " mins")
.extend(new NotificationCompat.WearableExtender().setContentIcon(R.drawable.uber_badge))
.extend(new NotificationCompat.WearableExtender().setBackground(bitmap))
.addAction(R.drawable.phone_call_image, null, callPendingIntent)
.setLargeIcon(bitmap);
mNotificationManager.notify(notifyId, notificationBuilder.build());
答案 0 :(得分:1)
AndroidManifest.xml中缺少持久性消息
我们需要在可穿戴应用和手机应用中添加CALL_PHONE权限。
<uses-permission android:name="android.permission.CALL_PHONE"/>