以下是我可以解决的代码:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + bundle.getString("mobilePhone")));
context.startActivity(intent);
答案 0 :(得分:3)
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" />
答案 1 :(得分:1)
您可以使用CallLog.Calls.getLastOutgoingCall获取最后一个拨出电话,然后使用您的意图来调用它。
答案 2 :(得分:0)
你走了。
在清单
中加入<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);