how can this? wanna add phone call log app, time (start , end), , if photo , name have in phone contact, wanna add photo , name in app. if not want set default photo. , wanna show phone number.
import java.sql.date; import java.text.simpledateformat; import java.util.locale; import android.app.activity; import android.database.cursor; import android.os.bundle; import android.provider.calllog; import android.widget.textview; public class mainactivity extends activity { textview phonenumber = null; textview date = null; // textview startend = null; textview duration = null; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); phonenumber = (textview) findviewbyid(r.id.txtphonenumber); date = (textview) findviewbyid(r.id.txtdate); // startendtime = (textview)findviewbyid(r.id.txtstartend); duration = (textview) findviewbyid(r.id.txtduration); getcalldetails(); } private void getcalldetails() { stringbuffer sbphonenumber = new stringbuffer(); stringbuffer sbdate = new stringbuffer(); // stringbuffer sbstart = new stringbuffer(); stringbuffer sbduration = new stringbuffer(); 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); int date = managedcursor.getcolumnindex(calllog.calls.date); int duration = managedcursor.getcolumnindex(calllog.calls.duration); while (managedcursor.movetonext()) { string phnum = managedcursor.getstring(number); string calltypecode = managedcursor.getstring(type); string strcalldate = managedcursor.getstring(date); date calldaytime = new date(long.valueof(strcalldate)); string datestr = new simpledateformat("dd/mm/yyyy", locale.english).format(calldaytime); string callduration = managedcursor.getstring(duration); string calltype = null; int callcode = integer.parseint(calltypecode); switch (callcode) { case calllog.calls.outgoing_type: calltype = "outgoing"; break; case calllog.calls.incoming_type: calltype = "incoming"; break; case calllog.calls.missed_type: calltype = "missed"; break; } sbphonenumber.append(phnum + " (" + calltype + ") "); sbdate.append(datestr); sbduration.append(callduration); } managedcursor.close(); phonenumber.settext(sbphonenumber); date.settext(sbdate); duration.settext(sbduration); } }
you have done call log part presume time duration etc. after fetching number call log have use contacts contact details .
refer
http://www.androidhub4you.com/2013/06/get-phone-contacts-details-in-android_6.html