2015-05-04 53 views
0

我有以下代碼但未打開撥號程序。如何在通知操作中發起來自Android Wear的呼叫

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()); 

回答

1

Persmissions在AndroidManifest.xml

我們需要添加CALL_PHONE許可,穿戴在身上的應用,以及手機應用不翼而飛。

<uses-permission android:name="android.permission.CALL_PHONE"/>