怎么得到最新的拨号没有android

时间:2012-02-01 12:29:27

标签: android

请帮我看看如何在Android手机中找到最新拨打的号码。

public static final String[] STR_FIELDS = {
    android.provider.CallLog.Calls.NUMBER, 
    android.provider.CallLog.Calls.TYPE,
    android.provider.CallLog.Calls.CACHED_NAME,
    android.provider.CallLog.Calls.CACHED_NUMBER_TYPE,
    android.provider.CallLog.Calls.DATE,
    android.provider.CallLog.Calls.DURATION,    android.provider.CallLog.Calls.CACHED_NUMBER_LABEL,android.provider.CallLog.Calls.NUMBER
    };

1 个答案:

答案 0 :(得分:2)

//获取callLog中的最后一个条目

            Cursor c = context.getContentResolver().query(Calls.CONTENT_URI, null, null, null, Calls.DATE + " DESC");
            if (c != null) {
                if (c.moveToFirst()) {
                    c.getString(c.getColumnIndex(Calls.CACHED_NAME));
                    c.getString(c.getColumnIndex(Calls.NUMBER)));
                }
                c.close();
            }