@Override
	protected void onResume() {
		AppUtility.getAppUtilityInstance().checkAndInitializeDatabase(this);
		super.onResume();
		setListAdapter();
		mealBreakTimeCounter = TimerUtility.getTimerUtilityInstance().getTimerObjectFromContainer(IAppConstants.TimerManagerConstants.TIMER_UTILITY_MEALBREAK_TIME);
		if(mealBreakTimeCounter != null) {
			if(mealBreakTimeCounter.isMealBreakRegistered()) {
				mealBreakTimeCounter.unregisterMealBreakCounterCallback();
			}
			mealBreakTimeCounter.registerMealBreakCounterCallback(this);
			
			headerTimeCounter = TimerUtility.getTimerUtilityInstance().getTimerObjectFromContainer(IAppConstants.TimerManagerConstants.TIMER_UTILITY_HEADER_TIMER_OBJECT);
			
			if (headerTimeCounter == null) {
				headerTimeCounter = new TimeCounter(this, IAppConstants.TimerManagerConstants.TIMER_UTILITY_HEADER_TIMER_OBJECT, false);
				TimerUtility.getTimerUtilityInstance().addTimerObjectToContainer(IAppConstants.TimerManagerConstants.TIMER_UTILITY_HEADER_TIMER_OBJECT, headerTimeCounter);
			}
			headerTimeCounter.registerTimeCounterCallback(this);
		}
		
	/*	if(AppConfig.getAppConfigInstance(this).isAppSyncing()) {
			disableSlider();
		} else {
			enableSlider();
		}*/
	}
    @Override
	public void updateClockTime(String newtime) {
		if ((mTimeTrackerTextView != null)
				&& (mTimeTrackerTextView.getVisibility() == View.VISIBLE)) {
			
			TimeCounter currentServiceRunningTime = AppUtility.getAppUtilityInstance().getCurrentRunningServiceTimeCounter();
			if(currentServiceRunningTime != null && AppUtility.getAppUtilityInstance().isApplicationStartAfterCrash()) {
				long currentSystemTime = currentServiceRunningTime.getCurrentSystemTime();
				long currentSystemTimeMins = currentSystemTime/(60*1000);
				/*long totalTimeInMins =  AppUtility.getAppUtilityInstance().getAccumulatedPauseTime(currentServiceRunningTime.getStartTimeStamp(), AppUtility.getAppUtilityInstance().getCurrentTimeStampWithoutSecs());
				currentSystemTimeMins -= totalTimeInMins;*/
				
				Date mCurrentDate = new Date(currentSystemTimeMins*60*1000);
				final SimpleDateFormat formatterTime = new SimpleDateFormat(IAppConstants.HOUR_MINS_FORMAT);
				formatterTime.setTimeZone(TimeZone.getTimeZone(IAppConstants.UTC_TIMEZONE));
				newtime = formatterTime.format(mCurrentDate);
			}
			
			mTimeTrackerTextView.setText(newtime);
		}
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
		super.onCreate(savedInstanceState);
		
		loadEnvironment();
		loadPresenter();
		showBaseScreen();
		registerUncaughtExceptionHandler();
        
		mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
		mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, “MyWakeLock”);
		AppUtility.getAppUtilityInstance().acquireWakeLock(mWakeLock);
	}
  /**
   * This method is activated on the Keystrokes we are listening to in this implementation. Here it
   * listens for Copy and Paste ActionCommands. Selections comprising non-adjacent cells result in
   * invalid selection and then copy action cannot be performed. Paste is done by aligning the upper
   * left corner of the selection with the 1st element in the current selection of the JTable.
   *
   * @param e
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().compareTo("Copy") == 0) {
      StringBuffer sbf = new StringBuffer();

      // Check to ensure we have selected only a continguous block of cells
      int numcols = jTable1.getSelectedColumnCount();
      int numrows = jTable1.getSelectedRowCount();
      int[] rowsselected = jTable1.getSelectedRows();
      int[] colsselected = jTable1.getSelectedColumns();

      if (rowsselected.length == 0 || colsselected.length == 0) {
        AppUtility.msgError(frame, "You have to select cells to copy !!");
        return;
      }

      String temp = "";
      for (int l = 0; l < numrows; l++) {
        for (int m = 0; m < numcols; m++) {
          if (jTable1.getValueAt(rowsselected[l], colsselected[m]) != null) {

            sbf.append(jTable1.getValueAt(rowsselected[l], colsselected[m]));

          } else {
            sbf.append("");
          }
          if (m < numcols - 1) {
            sbf.append("\t");
          }
        }
        sbf.append("\n");

        stsel = new StringSelection(sbf.toString());
        system = Toolkit.getDefaultToolkit().getSystemClipboard();
        system.setContents(stsel, stsel);
      }
    }

    if (e.getActionCommand().compareTo("Paste") == 0) {

      jTable1
          .getParent()
          .getParent()
          .getParent()
          .setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
      String table = "";

      if (debug) {
        System.out.println("Trying to Paste");
      }
      int startRow = 0; // (jTable1.getSelectedRows())[0];
      int startCol = 0; // (jTable1.getSelectedColumns())[0];

      while (jTable1.getRowCount() > 0) {
        ((DefaultTableModel) jTable1.getModel()).removeRow(0);
      }

      try {
        String trstring =
            (String) (system.getContents(this).getTransferData(DataFlavor.stringFlavor));
        if (debug) {
          System.out.println("String is: " + trstring);
        }
        StringTokenizer st1 = new StringTokenizer(trstring, "\n");

        if (insertRowsWhenPasting) {

          for (int i = 0; i < st1.countTokens(); i++) {
            ((DefaultTableModel) jTable1.getModel()).addRow(new Object[] {null, null});
          }
        }

        for (int i = 0; st1.hasMoreTokens(); i++) {

          rowstring = st1.nextToken();
          StringTokenizer st2 = new StringTokenizer(rowstring, "\t");

          for (int j = 0; st2.hasMoreTokens(); j++) {
            value = st2.nextToken();
            if (j < jTable1.getColumnCount()) {
              jTable1.setValueAt(value, i, j);
            }

            if (debug) {
              System.out.println(
                  "Putting " + value + "at row=" + (startRow + i) + "column=" + (startCol + j));
            }
          }
        }
      } catch (Exception ex) {
        ex.printStackTrace();

        ((DefaultTableModel) jTable1.getModel()).addRow(new Object[] {null, null});
      }

      jTable1
          .getParent()
          .getParent()
          .getParent()
          .setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    }
  }
	@Override
	public void unCaughtException(Context context, final String message) {
		AppUtility.getAppUtilityInstance().showCrashDialog(context, message, (MyApp)getApplication());
	}
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.timer_layout://Layout made clickable to increase click area.
		case R.id.menu_header_time_tracker:
			if(AppUtility.getAppUtilityInstance().isConnectionEstablished()) {
				AppUtility.getAppUtilityInstance().printTimerLogs();
				Intent timerDrawerIntent = new Intent(this, TimeDrawerActivity.class);
				timerDrawerIntent.putExtra(IAppConstants.IS_APP_ON_PAUSE_STATE, false);
				timerDrawerIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				
				Object setResult =  v.getTag(R.id.menu_header_time_tracker);
				
				if(setResult != null && (setResult instanceof Integer)) {
					int requestCode = Integer.parseInt(setResult.toString());
					if ((requestCode&0xffff0000) == 0) {
						timerDrawerIntent.putExtra(IAppConstants.StoreVisitSummary.EXTRA_NOTIFY_REFRESH, requestCode );
						startActivityForResult(timerDrawerIntent, requestCode);
					} else {
						startActivity(timerDrawerIntent);
					}
				} else {
					startActivity(timerDrawerIntent);
				}
			}else {
				AppLogs.d("NavigationDrawerSliderActivity", " connection not established!!");
			}
			break;

		case R.id.tv_header_subtitle: //Set click listener to subtitle to increase clickable area.
		case R.id.ll_header_clickable_menubar:
			if (button.getVisibility() == View.VISIBLE) {
				if (isToggle) {
					final ListPopupWindow mPopupMenuWindow = new ListPopupWindow(
							this);
					mPopupMenuWindow.setAnchorView(v);
					mPopupMenuWindow.setHeight(406);
					mPopupMenuWindow.setWidth(325);
					mPopupMenuWindow.getListView();
					mPopupMenuWindow.setBackgroundDrawable(getResources()
							.getDrawable(R.drawable.bg_popover_function_nine));
					if (menuItems != null) {
						menuAdapter = new FunctionMenuAdapter(this, menuItems,
								txtHeaderTypeface);
					}
					mPopupMenuWindow.setAdapter(menuAdapter);
					mPopupMenuWindow.setVerticalOffset(15);
					mPopupMenuWindow.setHorizontalOffset(-19);
					mPopupMenuWindow
							.setOnItemClickListener(new OnItemClickListener() {

								@Override
								public void onItemClick(AdapterView<?> parent,
										View view, int position, long arg3) {
									//TODO: Call through Presenter. Currently, the "this" instance is of HomeScreenActivity, hence making local method call.
									/*mPresenter.*/OnClickSelectedItem(menuItems
											.get(position).toString());
									mPopupMenuWindow.dismiss();
									isToggle = !isToggle;
								}
							});
					mPopupMenuWindow.show();
				}
				isToggle = !isToggle;
			}
			break;
		}
	}