Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. private void fetchCalenderEvents() {
  2.  
  3. Cursor cur = null;
  4. ContentResolver cr = getContentResolver();
  5. cur = cr.query(CalendarContract.Events.CONTENT_URI, EVENT_PROJECTION,
  6. null, null,null);
  7.  
  8. outputText.setText("");
  9.  
  10. long currenttime = new Date().getTime();
  11. //setContentView(R.layout.main);
  12. while (cur.moveToNext()) {
  13.  
  14. StringBuilder strbuldr = new StringBuilder();
  15. long calID = 0;
  16. String displayName = null;
  17. String accountName = null;
  18. String ownerName = null;
  19. String name = null;
  20. long startDate,endDate;
  21. String eventlocation = null;
  22. String eventOrganizer = null;
  23. String strDuration = null;
  24.  
  25. // Get the field values
  26. calID = cur.getLong(PROJECTION_ID_INDEX);
  27. displayName = cur.getString(PROJECTION_DISPLAY_NAME_INDEX);
  28. accountName = cur.getString(PROJECTION_ACCOUNT_NAME_INDEX);
  29. ownerName = cur.getString(PROJECTION_OWNER_ACCOUNT_INDEX);
  30. name = cur.getString(PROJECTION_EVENT_TITILE);
  31.  
  32. startDate = cur.getLong(PROJECTION_EVENT_DTSTART);
  33. endDate = cur.getLong(PROJECTION_EVENT_DATEEND);
  34.  
  35. Format df = DateFormat.getDateFormat(this);
  36. Format tf = DateFormat.getTimeFormat(this);
  37.  
  38. eventlocation = cur.getString(PROJECTION_EVENT_LOC);
  39. eventOrganizer = cur.getString(PROJECTION_EVENTT_ORGANIZER);
  40. strDuration = cur.getString(PROJECTION_EVENT_DURATION);
  41. if(startDate>=currenttime){
  42. strbuldr.append("Meeting "+name
  43. +" "
  44. +"has been Scheduled on date"+df.format(startDate)
  45. +" time "
  46. +tf.format(startDate)
  47. +" for duration "+strDuration);
  48.  
  49.  
  50. outputText.append(strbuldr.toString());
  51. outputText.append("n");
  52. if (outputText.getText().toString().trim().length() == 0) {
  53. Toast.makeText(getApplicationContext(),
  54. "Please enter your message.", Toast.LENGTH_LONG).show();
  55. return;
  56. }
  57. else{
  58. speakUSLocale();
  59. confirmTTSData();
  60. break;
  61. }
  62.  
  63.  
  64. }else{
  65. Log.d(DEBUG_TAG, "Old events");
  66. }
  67. }
  68.  
  69. cur.close();
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement