Reputation: 29
Here's the code that I could work out:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + bundle.getString("mobilePhone")));
context.startActivity(intent);
Upvotes: 1
Views: 582
Reputation: 425
String uri = "tel:" + CallLog.Calls.getLastOutgoingCall(getApplicationContext()).trim();
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
startActivity(intent);
and add to the manifest this permission
<uses-permission android:name="android.permission.READ_CALL_LOG" />
Upvotes: 3
Reputation: 28093
Here you go.
Include <uses-permission android:name="android.permission.READ_CONTACTS"/>
in manifest
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);
Upvotes: 0
Reputation: 4157
You can use CallLog.Calls.getLastOutgoingCall to get the last outgoing call and then use your intent to call it.
Upvotes: 1