Thursday, 13 June 2013

Call Log Apps For Android


This Application Quickly access Call log from your android device and display in android TextView. For that you need to create application give name as myCalllog.

1. You need to look your main.m file first. modify main.m code as given below tack one TextView so we can add call log data in TextView
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:layout_height="match_parent" >  
   <TextView  
     android:id="@+id/textview"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:padding="10px"  
     android:scrollbars="vertical"  
     android:text="@string/hello_world"  
     tools:context=".MainActivity" />  
 </RelativeLayout>  

2.Now you need to change your java file as per our requirement you need to get your TextView by using findViewById method and also set scroll enable so more record it is scroll so in your onCreate() method put below line of code.

  tv=(TextView) findViewById(R.id.textview);  
  tv.setMovementMethod(new ScrollingMovementMethod());  

3.You have get your TextView now you need to move forword get call log data in cursor so you need one StringBuffer and Cursor for moving each and every record and get Incoming call,Outgoing call and Miss call put below TextView code

 StringBuffer sb = 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);  
 sb.append("Call Details :")  
 while (managedCursor.moveToNext()) {  
           String phNumber = managedCursor.getString(number);  
           String callType = managedCursor.getString(type);  
           String callDate = managedCursor.getString(date);  
           Date callDayTime = new Date(Long.valueOf(callDate));  
           String callDuration = managedCursor.getString(duration);  
           String dir = null;  
           int dircode = Integer.parseInt(callType);  
          switch (dircode) {  
                case CallLog.Calls.OUTGOING_TYPE:  
                     dir = "OUTGOING";  
                     break;  
                case CallLog.Calls.INCOMING_TYPE:  
                     dir = "INCOMING";  
                     break;  
                case CallLog.Calls.MISSED_TYPE:  
                     dir = "MISSED";  
                     break;  
                }  
                sb.append("\nPhone Number:--- " + phNumber + " \nCall Type:--- "  
                          + dir + " \nCall Date:--- " + callDayTime  
                          + " \nCall duration in sec :--- " + callDuration);  
                sb.append("\n----------------------------------");  
 }  
 managedCursor.close();  
 tv.setText(sb);  

4.Your Call log application is ready to build now build and run your application check output in your simulator.

My Android Applications

Download Hanuman HD Wallpaper on Google Play

Download Live Currency Exchange Rates on Google Play

Download iSIM Info on Google Play

Download Find Droid on Google Play