├── .classpath ├── .gitattributes ├── .gitignore ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── README.md ├── ic_launcher-web.png ├── libs └── android-support-v4.jar ├── proguard-project.txt ├── project.properties ├── res ├── drawable-hdpi │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── drawable-xxhdpi │ └── ic_launcher.png ├── layout │ └── activity_main.xml ├── menu │ └── main.xml ├── values-v11 │ └── styles.xml ├── values-v14 │ └── styles.xml ├── values-w820dp │ └── dimens.xml └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── src └── com └── example └── phonehistory ├── DBHelper.java ├── History.java ├── MainActivity.java └── PhListener.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | # ========================= 29 | # Operating System Files 30 | # ========================= 31 | 32 | # OSX 33 | # ========================= 34 | 35 | .DS_Store 36 | .AppleDouble 37 | .LSOverride 38 | 39 | # Thumbnails 40 | ._* 41 | 42 | # Files that might appear on external disk 43 | .Spotlight-V100 44 | .Trashes 45 | 46 | # Directories potentially created on remote AFP share 47 | .AppleDB 48 | .AppleDesktop 49 | Network Trash Folder 50 | Temporary Items 51 | .apdisk 52 | 53 | # Windows 54 | # ========================= 55 | 56 | # Windows image file caches 57 | Thumbs.db 58 | ehthumbs.db 59 | 60 | # Folder config file 61 | Desktop.ini 62 | 63 | # Recycle Bin used on file shares 64 | $RECYCLE.BIN/ 65 | 66 | # Windows Installer files 67 | *.cab 68 | *.msi 69 | *.msm 70 | *.msp 71 | 72 | # Windows shortcuts 73 | *.lnk 74 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PhoneHistory 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Android-Call-Log-Details 2 | ======================== 3 | 4 | Android call log project used Phone sate listener to listen changes in phone state and content observer is used to keep track on changes in call logs. SQLite data base is used to keep all details that will be use to show on layout. 5 | 6 | ![Android Call Log](http://2.bp.blogspot.com/-dmF4cLV1D9w/VJf0Jc14i1I/AAAAAAAAA0E/LSvB9FbD1RU/s1600/Incoming-and-outgoing-call-example.png) 7 | 8 | Tutorial available on my blog: http://www.coders-hub.com/2014/12/call-log-details-after-ending-call.html 9 | -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmimohsin/Android-Call-Log-Details/6cea4279ab561d8086ecafc04a7c83ee75a56d07/ic_launcher-web.png -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmimohsin/Android-Call-Log-Details/6cea4279ab561d8086ecafc04a7c83ee75a56d07/libs/android-support-v4.jar -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | android.library.reference.1=../appcompat_v7 16 | -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmimohsin/Android-Call-Log-Details/6cea4279ab561d8086ecafc04a7c83ee75a56d07/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmimohsin/Android-Call-Log-Details/6cea4279ab561d8086ecafc04a7c83ee75a56d07/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmimohsin/Android-Call-Log-Details/6cea4279ab561d8086ecafc04a7c83ee75a56d07/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmimohsin/Android-Call-Log-Details/6cea4279ab561d8086ecafc04a7c83ee75a56d07/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PhoneHistory 5 | Hello world! 6 | Delete History 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/com/example/phonehistory/DBHelper.java: -------------------------------------------------------------------------------- 1 | package com.example.phonehistory; 2 | 3 | import android.content.Context; 4 | import android.database.Cursor; 5 | import android.database.sqlite.SQLiteDatabase; 6 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 7 | import android.database.sqlite.SQLiteOpenHelper; 8 | 9 | public class DBHelper extends SQLiteOpenHelper{ 10 | 11 | public DBHelper(Context context, String name, CursorFactory factory, 12 | int version) { 13 | super(context, name, factory, version); 14 | // TODO Auto-generated constructor stub 15 | } 16 | 17 | @Override 18 | public void onCreate(SQLiteDatabase db) { 19 | // TODO Auto-generated method stub 20 | db.execSQL("create table if not exists call_history(number varchar, date varchar, time varchar, duration varchar, type varchar)"); 21 | } 22 | 23 | @Override 24 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 25 | // TODO Auto-generated method stub 26 | db.execSQL("DROP TABLE IF EXISTS call_history"); 27 | onCreate(db); 28 | } 29 | 30 | public boolean insertdata(String number, String date, String time,String duration, String type) 31 | { 32 | SQLiteDatabase sdb=this.getWritableDatabase(); 33 | sdb.execSQL("insert into call_history values('"+number+"','"+date+"','"+time+"','"+duration+"','"+type+"')"); 34 | return true; 35 | } 36 | 37 | public Cursor getData() 38 | { 39 | SQLiteDatabase sdb=this.getReadableDatabase(); 40 | Cursor c=sdb.rawQuery("select * from call_history", null); 41 | return c; 42 | } 43 | public void deleteTable() 44 | { 45 | SQLiteDatabase db=this.getWritableDatabase(); 46 | db.execSQL("DROP TABLE IF EXISTS call_history"); 47 | onCreate(db); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/com/example/phonehistory/History.java: -------------------------------------------------------------------------------- 1 | package com.example.phonehistory; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import android.annotation.SuppressLint; 6 | import android.app.Activity; 7 | import android.content.Context; 8 | import android.content.SharedPreferences; 9 | import android.database.ContentObserver; 10 | import android.database.Cursor; 11 | import android.os.Handler; 12 | import android.provider.CallLog; 13 | 14 | @SuppressLint("SimpleDateFormat") 15 | public class History extends ContentObserver { 16 | 17 | Context c; 18 | 19 | public History(Handler handler, Context cc) { 20 | // TODO Auto-generated constructor stub 21 | super(handler); 22 | c=cc; 23 | } 24 | 25 | @Override 26 | public boolean deliverSelfNotifications() { 27 | return true; 28 | } 29 | 30 | @Override 31 | public void onChange(boolean selfChange) { 32 | // TODO Auto-generated method stub 33 | super.onChange(selfChange); 34 | SharedPreferences sp=c.getSharedPreferences("ZnSoftech", Activity.MODE_PRIVATE); 35 | String number=sp.getString("number", null); 36 | if(number!=null) 37 | { 38 | getCalldetailsNow(); 39 | sp.edit().putString("number", null).commit(); 40 | } 41 | } 42 | 43 | private void getCalldetailsNow() { 44 | // TODO Auto-generated method stub 45 | 46 | Cursor managedCursor=c.getContentResolver().query(CallLog.Calls.CONTENT_URI, null, null, null, android.provider.CallLog.Calls.DATE + " DESC"); 47 | 48 | int number = managedCursor.getColumnIndex( CallLog.Calls.NUMBER ); 49 | int duration1 = managedCursor.getColumnIndex( CallLog.Calls.DURATION); 50 | int type1=managedCursor.getColumnIndex(CallLog.Calls.TYPE); 51 | int date1=managedCursor.getColumnIndex(CallLog.Calls.DATE); 52 | 53 | if( managedCursor.moveToFirst() == true ) { 54 | String phNumber = managedCursor.getString(number); 55 | String callDuration = managedCursor.getString(duration1); 56 | 57 | String type=managedCursor.getString(type1); 58 | String date=managedCursor.getString(date1); 59 | 60 | String dir = null; 61 | int dircode = Integer.parseInt(type); 62 | switch (dircode) 63 | { 64 | case CallLog.Calls.OUTGOING_TYPE: 65 | dir = "OUTGOING"; 66 | break; 67 | case CallLog.Calls.INCOMING_TYPE: 68 | dir = "INCOMING"; 69 | break; 70 | case CallLog.Calls.MISSED_TYPE: 71 | dir = "MISSED"; 72 | break; 73 | default: 74 | dir = "MISSED"; 75 | break; 76 | } 77 | 78 | SimpleDateFormat sdf_date = new SimpleDateFormat("dd/MM/yyyy"); 79 | SimpleDateFormat sdf_time = new SimpleDateFormat("h:mm a"); 80 | // SimpleDateFormat sdf_dur = new SimpleDateFormat("KK:mm:ss"); 81 | 82 | String dateString = sdf_date.format(new Date(Long.parseLong(date))); 83 | String timeString = sdf_time.format(new Date(Long.parseLong(date))); 84 | // String duration_new=sdf_dur.format(new Date(Long.parseLong(callDuration))); 85 | 86 | DBHelper db=new DBHelper(c, "ZnSoftech.db", null, 2); 87 | db.insertdata(phNumber, dateString, timeString, callDuration, dir); 88 | 89 | } 90 | 91 | managedCursor.close(); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/com/example/phonehistory/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.phonehistory; 2 | 3 | import android.support.v7.app.ActionBarActivity; 4 | import android.database.Cursor; 5 | import android.os.Bundle; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.widget.TextView; 9 | 10 | 11 | public class MainActivity extends ActionBarActivity { 12 | 13 | DBHelper db; 14 | TextView tv; 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_main); 20 | tv=(TextView)findViewById(R.id.text); 21 | tv.setText(""); 22 | 23 | db=new DBHelper(this, "ZnSoftech.db", null, 2); 24 | 25 | Cursor c=db.getData(); 26 | 27 | if(c.getCount()>0) 28 | { 29 | c.moveToFirst(); 30 | do 31 | { 32 | String number=c.getString(0); 33 | String date=c.getString(1); 34 | String time=c.getString(2); 35 | String duration=c.getString(3); 36 | String type=c.getString(4); 37 | 38 | tv.append("Number:"+number+"\nDate:"+date+"\nTime:"+time+"\nDuration:"+duration+"\nCall Type:"+type+"\n\n"); 39 | }while(c.moveToNext()); 40 | } 41 | else 42 | { 43 | tv.setText("No Incoming and Outgoing call history exists!!!"); 44 | } 45 | 46 | } 47 | 48 | 49 | @Override 50 | public boolean onCreateOptionsMenu(Menu menu) { 51 | // Inflate the menu; this adds items to the action bar if it is present. 52 | getMenuInflater().inflate(R.menu.main, menu); 53 | return true; 54 | } 55 | 56 | @Override 57 | public boolean onOptionsItemSelected(MenuItem item) { 58 | // Handle action bar item clicks here. The action bar will 59 | // automatically handle clicks on the Home/Up button, so long 60 | // as you specify a parent activity in AndroidManifest.xml. 61 | int id = item.getItemId(); 62 | if (id == R.id.action_settings) { 63 | db.deleteTable(); 64 | tv.setText("No Incoming and Outgoing call history exists!!!"); 65 | return true; 66 | } 67 | return super.onOptionsItemSelected(item); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/com/example/phonehistory/PhListener.java: -------------------------------------------------------------------------------- 1 | package com.example.phonehistory; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.BroadcastReceiver; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.content.SharedPreferences; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | import android.provider.CallLog; 12 | import android.telephony.TelephonyManager; 13 | 14 | @SuppressLint("SimpleDateFormat") public class PhListener extends BroadcastReceiver{ 15 | 16 | @Override 17 | public void onReceive(Context c, Intent i) { 18 | // TODO Auto-generated method stub 19 | Bundle bundle=i.getExtras(); 20 | 21 | if(bundle==null) 22 | return; 23 | 24 | SharedPreferences sp=c.getSharedPreferences("ZnSoftech", Activity.MODE_PRIVATE); 25 | 26 | String s=bundle.getString(TelephonyManager.EXTRA_STATE); 27 | 28 | if(i.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) 29 | { 30 | String number=i.getStringExtra(Intent.EXTRA_PHONE_NUMBER); 31 | sp.edit().putString("number", number).commit(); 32 | sp.edit().putString("state", s).commit(); 33 | } 34 | 35 | else if(s.equals(TelephonyManager.EXTRA_STATE_RINGING)) 36 | { 37 | String number=bundle.getString("incoming_number"); 38 | sp.edit().putString("number", number).commit(); 39 | sp.edit().putString("state", s).commit(); 40 | } 41 | 42 | else if(s.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) 43 | { 44 | sp.edit().putString("state", s).commit(); 45 | } 46 | 47 | else if(s.equals(TelephonyManager.EXTRA_STATE_IDLE)) 48 | { 49 | String state=sp.getString("state", null); 50 | if(!state.equals(TelephonyManager.EXTRA_STATE_IDLE)) 51 | { 52 | sp.edit().putString("state", null).commit(); 53 | History h=new History(new Handler(),c); 54 | c.getContentResolver().registerContentObserver(CallLog.Calls.CONTENT_URI, true, h); 55 | } 56 | sp.edit().putString("state", s).commit(); 57 | } 58 | 59 | } 60 | 61 | } 62 | --------------------------------------------------------------------------------