Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 43 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. public class Getting_Call_log_Service extends Service {
  2.  
  3. //variables of getting call logs
  4. private String ph_number;
  5. private String temp_name;
  6. private String real_name;
  7. private String call_type;
  8. private String dir;
  9. private String call_date;
  10. private String call_duration;
  11. private Date call_day_time;
  12. private SQLite_database_helper_class myDb;
  13.  
  14. public  class callsThread implements Runnable{
  15.     callsThread(){}
  16.  
  17.     @Override
  18.     public void run() {
  19.  
  20.             myDb=new SQLite_database_helper_class(getApplicationContext());
  21.             //codes of extracting call logs
  22.             Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI,
  23.                     null,null,null,null);
  24.  
  25.             int number=cursor.getColumnIndex(CallLog.Calls.NUMBER);//to get the index of phoneNumber column
  26.             int name = cursor.getColumnIndex(CallLog.Calls.CACHED_NAME);//to get the index of contact name column
  27.             int type = cursor.getColumnIndex(CallLog.Calls.TYPE);//to get the call type index
  28.             int callDate = cursor.getColumnIndex(CallLog.Calls.DATE);//to get the date of calling
  29.             int callDuration = cursor.getColumnIndex(CallLog.Calls.DURATION);//to get the duration of calling
  30.  
  31.  
  32.             cursor.moveToFirst();
  33.  
  34.                 do {
  35.  
  36.                     //extracting values from phone history
  37.                     ph_number=cursor.getString(number);
  38.                     temp_name=cursor.getString(name);
  39.                     if (temp_name==null){
  40.                         real_name="Annonymous caller!";
  41.                     }else {
  42.                         real_name=temp_name;
  43.                     }
  44.                     call_type=cursor.getString(type);
  45.                     int dir_code=Integer.parseInt(call_type);
  46.                     switch (dir_code) {
  47.                         case CallLog.Calls.INCOMING_TYPE:
  48.                             dir = "INCOMING CALL";
  49.                             break;
  50.                         case CallLog.Calls.OUTGOING_TYPE:
  51.                             dir = "OUTGOING CALL";
  52.                             break;
  53.  
  54.                         case CallLog.Calls.MISSED_TYPE:
  55.                             dir = "MISSED CALL";
  56.                             break;
  57.                         case CallLog.Calls.REJECTED_TYPE:
  58.                             dir = "REJECTED CALL";
  59.                             break;
  60.                         case CallLog.Calls.ANSWERED_EXTERNALLY_TYPE:
  61.                             dir = "ANSWERED EXTERNALLY";
  62.                             break;
  63.                         case CallLog.Calls.BLOCKED_TYPE:
  64.                             dir = "BLOCKED NUMBER";
  65.                             break;
  66.                         case CallLog.Calls.VOICEMAIL_TYPE:
  67.                             dir = "VOICEMAIL";
  68.                             break;
  69.                     }
  70.                     call_date=cursor.getString(callDate);
  71.                     call_day_time=new Date(Long.valueOf(call_date));
  72.  
  73.                     call_duration=cursor.getString(callDuration);
  74.                     //end of extraction
  75.  
  76.                             myDb.saving_call_logs(ph_number,real_name,dir,
  77.                                     call_day_time.toString(), call_duration);
  78.                 }while (cursor.moveToNext());
  79.                 cursor.close();
  80.  
  81.         }
  82.     }
  83.  
  84. public void calls_fromPhone(){
  85.  
  86.     Thread callThread=new Thread(new callsThread());
  87.     callThread.start();
  88.  
  89. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top