我有联系人的电话号码和姓名。有了这些信息,我该如何启动联系人:
我只能启动通话记录和通讯录的启动活动。相反,我想直接导航到一个人的记录。知道如何实现这个目标吗?
答案 0 :(得分:0)
这对我来说很好。请看一下。
contactNumber = Uri.encode(contactNumber);
int phoneCallLogID = new Random().nextInt();
Cursor callLogLookupCursor = context.getContentResolver().query(Uri.withAppendedPath(android.provider.CallLog.Calls.CONTENT_FILTER_URI,contactNumber),null, null, null, null);
while(callLogLookupCursor.moveToNext()){
phoneCallLogID = callLogLookupCursor.getInt(callLogLookupCursor.getColumnIndexOrThrow(CallLog.Calls._ID));
}
callLogLookupCursor.close();
Uri uri = Uri.withAppendedPath(
android.provider.CallLog.Calls.CONTENT_URI, String.valueOf(phoneCallLogID));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
startActivityForResult(intent,0);