Johnny
Johnny

Reputation: 2910

Android: How to fire CallDetailActivity intent?

I am super new to android, how to fire CallDetailActivity intent?

From LogCat:

Intent {dat=content://call_log/calls/48 cmp=com.android.contacts/.CallDetailActivity}

48 is the id, from CallLog.

How do I construct the intent to fire the event like above? given id

Regards,

Johnny

Upvotes: 0

Views: 203

Answers (2)

A.Alqadomi
A.Alqadomi

Reputation: 1589

based on the solution provided by CommonsWare here is the code : it would retrieve the latest entry to the log and open the Call Detail Activity

Cursor managedCursor = managedQuery(CallLog.Calls.CONTENT_URI, null, null, null, "DATE DESC");
        int id=0;
        if (managedCursor.moveToNext()) {
            id = managedCursor.getInt(managedCursor.getColumnIndex(CallLog.Calls._ID));
        }
        managedCursor.close();
        Intent showCallLog = new Intent();
        showCallLog.setAction(Intent.ACTION_VIEW);
        Uri uri = ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI, id);
        showCallLog.setData(uri);
        startActivity(showCallLog);

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007614

Create an ACTION_VIEW Intent with the Uri to the call. If all you have is just the ID, try using ContentUris and withAppendedId() to add your ID to CallLog.Calls.CONTENT_URI.

Upvotes: 1

Related Questions