Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************************
- **SCROLL DOWN FOR LOGCAT OUTPUT **
- **********************************/
- private class ScreenQueryTask extends AsyncTask<String, Void, Cursor> {
- Messenger replyTo;
- int arg1;
- public ScreenQueryTask(Messenger msgr, int arg1) {
- this.replyTo = msgr;
- this.arg1=arg1;
- }
- protected Cursor doInBackground(String... screenQuery) {
- //here we want to loop through the screen cursor and add names to the records from the contact list
- Cursor screenCursor = null;
- String display_name = "";
- String _id = "";
- String number = "";
- String time = "";
- String customer = "";
- String duration = "";
- String duration_billed = "";
- String pending = "";
- String call_id = "";
- String job_id = "";
- String job_name = "";
- String job_num = "";
- MatrixCursor finalCursor = new MatrixCursor(
- new String[] {
- "android_call_id",
- mDbCallTable.COLUMN_PHONE,
- mDbCallTable.COLUMN_TIME,
- mDbCallTable.COLUMN_DURATION,
- mDbCallTable.COLUMN_DURATION_BILLED,
- mDbCallTable.COLUMN_PENDING,
- mDbCallTable.COLUMN_CALL_ID,
- mDbCallTable.COLUMN_JOB_ID,
- mDbCallTable.COLUMN_CUSTOMER,
- "android_job_id",
- mDbJobTable.COLUMN_NAME,
- mDbJobTable.COLUMN_JOB_NUMBER,
- "display_name"
- });
- String[] projection = new String[] { ContactsContract.Data.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER };
- try {
- screenCursor = mDb.rawQuery(screenQuery[0], null);
- screenCursor.moveToFirst();
- } catch(Exception e) {
- //
- }
- Cursor cursor = null;
- do {
- try {
- //get all the columns from the screenCursor
- _id = screenCursor.getString(screenCursor.getColumnIndex("android_call_id"));
- number = screenCursor.getString(screenCursor.getColumnIndex(mDbCallTable.COLUMN_PHONE));
- time = screenCursor.getString(screenCursor.getColumnIndex(mDbCallTable.COLUMN_TIME));
- customer = screenCursor.getString(screenCursor.getColumnIndex(mDbCallTable.COLUMN_CUSTOMER));
- duration = screenCursor.getString(screenCursor.getColumnIndex(mDbCallTable.COLUMN_DURATION));
- duration_billed = screenCursor.getString(screenCursor.getColumnIndex(mDbCallTable.COLUMN_DURATION_BILLED));
- pending = screenCursor.getString(screenCursor.getColumnIndex(mDbCallTable.COLUMN_PENDING));
- call_id = screenCursor.getString(screenCursor.getColumnIndex(mDbCallTable.COLUMN_CALL_ID));
- job_id = screenCursor.getString(screenCursor.getColumnIndex("android_job_id"));
- job_name = screenCursor.getString(screenCursor.getColumnIndex(mDbJobTable.COLUMN_NAME));
- job_num = screenCursor.getString(screenCursor.getColumnIndex(mDbJobTable.COLUMN_JOB_NUMBER));
- //Log.i(LOG_TAG, "record: "+duration);
- ContentResolver contentResolver = getContentResolver();
- if(number.length()==7) {
- cursor = getContentResolver().query(ContactsContract.Data.CONTENT_URI, null,
- ContactsContract.CommonDataKinds.Phone.NUMBER+" LIKE ?",
- new String[] { "%"+number },
- null);
- } else if(number.length()==10) {
- cursor = getContentResolver().query(ContactsContract.Data.CONTENT_URI, null,
- "("+ContactsContract.CommonDataKinds.Phone.NUMBER+"=? AND LENGTH("+ContactsContract.CommonDataKinds.Phone.NUMBER+")=7) OR ("+ContactsContract.CommonDataKinds.Phone.NUMBER+"=? AND LENGTH("+ContactsContract.CommonDataKinds.Phone.NUMBER+")=10)",
- new String[] { number.substring(3), number },
- null);
- } else {
- cursor = getContentResolver().query(ContactsContract.Data.CONTENT_URI, null,
- ContactsContract.CommonDataKinds.Phone.NUMBER+"=?",
- new String[] { number },
- null);
- }
- } catch(Exception e) {
- //
- }
- try {
- cursor.moveToFirst();
- display_name = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
- if(_id!=null) {
- finalCursor.addRow(new String[] {_id, number, time, duration, duration_billed, pending, call_id, job_id, customer, job_id, job_name, job_num, display_name});
- }
- try {
- Log.i(LOG_TAG, "---------------------------");
- Log.i(LOG_TAG, "_id: "+_id);
- Log.i(LOG_TAG, "num: "+number);
- Log.i(LOG_TAG, "tim: "+time);
- Log.i(LOG_TAG, "dur: "+duration);
- Log.i(LOG_TAG, "drb: "+duration_billed);
- Log.i(LOG_TAG, "cid: "+call_id);
- Log.i(LOG_TAG, "job: "+job_name);
- Log.i(LOG_TAG, "jid: "+job_id);
- Log.i(LOG_TAG, "jnm: "+job_num);
- Log.i(LOG_TAG, "cnm: "+customer);
- Log.i(LOG_TAG, "pnd: "+pending);
- Log.i(LOG_TAG, "dnm: "+display_name);
- } catch(Exception e2) {
- Log.e(LOG_TAG, "problem printing value.");
- }
- } catch(Exception e) {
- Log.e(LOG_TAG, "error building matrix cursor for display: "+e.getMessage());
- try {
- Log.e(LOG_TAG, "---------------------------");
- Log.e(LOG_TAG, "_id: "+_id);
- Log.e(LOG_TAG, "num: "+number);
- Log.e(LOG_TAG, "tim: "+time);
- Log.e(LOG_TAG, "dur: "+duration);
- Log.e(LOG_TAG, "drb: "+duration_billed);
- Log.e(LOG_TAG, "cid: "+call_id);
- Log.e(LOG_TAG, "job: "+job_name);
- Log.e(LOG_TAG, "jid: "+job_id);
- Log.e(LOG_TAG, "jnm: "+job_num);
- Log.e(LOG_TAG, "cnm: "+customer);
- Log.e(LOG_TAG, "pnd: "+pending);
- Log.e(LOG_TAG, "dnm: "+display_name);
- } catch(Exception e2) {
- Log.e(LOG_TAG, "problem printing value.");
- }
- }
- } while(screenCursor.moveToNext());
- return finalCursor;
- }
- protected void onPostExecute(Cursor resultCursor) {
- try {
- replyTo.send(Message.obtain(null, MinutemaidService.MESSAGE_QUERY_RESULT, this.arg1, 0, (Object)resultCursor));
- Log.i(LOG_TAG, "sending reply to query request");
- showNotification();
- } catch (Exception e) {
- Log.e(LOG_TAG, "oops: "+e.getMessage());
- }
- }
- };
- /***** OUTPUT IN LOGCAT ********/
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): error building matrix cursor for display: Index 0 requested, with a size of 0
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): ---------------------------
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): _id: 44
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): num: 6153456350
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): tim: 1311108541019
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): dur: 374
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): drb: 720
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): cid: 425
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): job: null
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): jid: null
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): jnm: null
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): cnm: null
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): pnd: 1
- 07-20 16:10:57.778: ERROR/Minutemaid - Service(5271): dnm:
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): error building matrix cursor for display: Index 0 requested, with a size of 0
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): ---------------------------
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): _id: 45
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): num: 8008480981
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): tim: 1311118955412
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): dur: 63
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): drb: 360
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): cid: 426
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): job: null
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): jid: null
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): jnm: null
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): cnm: null
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): pnd: 1
- 07-20 16:10:57.808: ERROR/Minutemaid - Service(5271): dnm:
- 07-20 16:10:57.878: INFO/Minutemaid - Service(5271): ---------------------------
- 07-20 16:10:57.878: INFO/Minutemaid - Service(5271): _id: 46
- 07-20 16:10:57.878: INFO/Minutemaid - Service(5271): num: 7133737664
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): tim: 1311122175521
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): dur: 17
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): drb: 360
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): cid: 428
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): job: null
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): jid: null
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): jnm: null
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): cnm: null
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): pnd: 1
- 07-20 16:10:57.888: INFO/Minutemaid - Service(5271): dnm: Julia Walsh
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): ---------------------------
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): _id: 47
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): num: 7133737664
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): tim: 1311126243267
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): dur: 40
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): drb: 360
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): cid: 430
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): job: null
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): jid: null
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): jnm: null
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): cnm: null
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): pnd: 1
- 07-20 16:10:57.908: INFO/Minutemaid - Service(5271): dnm: Julia Walsh
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): ---------------------------
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): _id: 48
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): num: 7133737664
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): tim: 1311126566511
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): dur: 66
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): drb: 360
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): cid: 431
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): job: null
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): jid: null
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): jnm: null
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): cnm: null
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): pnd: 1
- 07-20 16:10:57.938: INFO/Minutemaid - Service(5271): dnm: Julia Walsh
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): ---------------------------
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): _id: 49
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): num: 7133737664
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): tim: 1311127116451
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): dur: 5501
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): drb: 5760
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): cid: 432
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): job: null
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): jid: null
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): jnm: null
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): cnm: null
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): pnd: 1
- 07-20 16:10:57.958: INFO/Minutemaid - Service(5271): dnm: Julia Walsh
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): error building matrix cursor for display: Index 0 requested, with a size of 0
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): ---------------------------
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): _id: 51
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): num: 6157261094
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): tim: 1311193655509
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): dur: 5
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): drb: 360
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): cid: 434
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): job: null
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): jid: null
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): jnm: null
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): cnm: null
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): pnd: 1
- 07-20 16:10:57.988: ERROR/Minutemaid - Service(5271): dnm: Julia Walsh
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): ---------------------------
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): _id: 50
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): num: 6157262578
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): tim: 1311184725046
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): dur: 37
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): drb: 360
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): cid: 433
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): job: null
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): jid: null
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): jnm: null
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): cnm: Conceptual Systems
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): pnd: 1
- 07-20 16:10:58.008: INFO/Minutemaid - Service(5271): dnm: Conceptual Systems
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement