这是我可以解决的代码:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + bundle.getString("mobilePhone")));
context.startActivity(intent);
String uri = "tel:" + CallLog.Calls.getLastOutgoingCall(getApplicationContext()).trim();
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
startActivity(intent);
并将此权限添加到清单中
<uses-permission android:name="android.permission.READ_CALL_LOG" />
您可以使用 CallLog.Calls.getLastOutgoingCall 获取最后一个拨出电话,然后使用您的意图调用它。
干得好。
包含<uses-permission android:name="android.permission.READ_CONTACTS"/>
在清单中
String lastNumber = "";
Cursor managedCursor = managedQuery(CallLog.Calls.CONTENT_URI, null,
null, null, null);
int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE);
while (managedCursor.moveToNext()) {
String phNumber = managedCursor.getString(number);
String callType = managedCursor.getString(type);
int dircode = Integer.parseInt(callType);
switch (dircode) {
case CallLog.Calls.OUTGOING_TYPE:
lastNumber = phNumber;
break;
}
if (lastNumber.length() != 0)
break;
}
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + lastNumber));
context.startActivity(intent);