1

这是我可以解决的代码:

Intent intent = new Intent(Intent.ACTION_CALL);

intent.setData(Uri.parse("tel:" + bundle.getString("mobilePhone")));
context.startActivity(intent);
4

3 回答 3

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" />
于 2013-02-16T09:24:29.247 回答
1

您可以使用 CallLog.Calls.getLastOutgoingCall 获取最后一个拨出电话,然后使用您的意图调用它。

http://developer.android.com/reference/android/provider/CallLog.Calls.html#getLastOutgoingCall(android.content.Context )

于 2012-06-13T13:02:48.313 回答
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);
于 2012-06-13T13:16:20.453 回答