Android 获取上一次拨号信息方法
方法如下:
import android.content.ContentResolver;
…………
……………………
public static String getLastOutgoingCall(Context context) {
final ContentResolver resolver = context.getContentResolver();
Cursor c = null;
try {
c = resolver.query(
Calls.CONTENT_URI,
new String[] {Calls.NUMBER},
Calls.TYPE + " = " + Calls.OUTGOING_TYPE,
null,
Calls.DEFAULT_SORT_ORDER + " LIMIT 1");
if (c == null || !c.moveToFirst()) {
return "";
}
return c.getString(0); //返回上一次拨号信息,如果清空通话记录,将没有上一次拨号记录
} finally {
if (c != null) c.close();
}
}
…………………………