[ Home ]

Time Recording: Public Services

Time Recording provides services for integration in other apps (like "Tasker"), and for developers who want to use these on their own.

Packages (Free, Pro)
com.dynamicg.timerecording
com.dynamicg.timerecording.pro

BroadcastReceivers
com.dynamicg.timerecording.CHECK_IN
com.dynamicg.timerecording.CHECK_OUT
com.dynamicg.timerecording.PUNCH
com.dynamicg.timerecording.START_NEW_TASK
com.dynamicg.timerecording.DATA_EXPORT
com.dynamicg.timerecording.GET_INFO

Activities
com.dynamicg.timerecording.activity.CHECK_IN
com.dynamicg.timerecording.activity.CHECK_OUT
com.dynamicg.timerecording.activity.PUNCH
com.dynamicg.timerecording.activity.SWITCH_TASK

Set specific task
• Set the "com.dynamicg.timerecording.TASK" extra. Value is the numeric Task ID as displayed on the "Edit task" screen.
• Alternatively, set the "com.dynamicg.timerecording.TASK_NAME" extra with the given task name. If the same tasks exists for different clients, use format "taskname[[clientname]]".
• Tasker info: when setting parameters in Tasker, use this notation: com.dynamicg.timerecording.TASK:{ID}

Set specific time
• Set the "com.dynamicg.timerecording.TIME" extra.
• Format is "hh24:mm" (i.e. 00:00 to 23:59).
• If you need to set the "Validity date" to next day: use format "hh24:mm+1", e.g. "00:45+1"

Set work unit notes
• Set the "com.dynamicg.timerecording.NOTES" extra

GET_INFO
• This is for developers who want to integrate Time Recording status information in their own apps or widgets. GET_INFO sends current task, running total work time, current daily and weekly "delta", and other data to your BroadcastReceiver.
• Sample project is available here: TimeRecInfoGetter-src.zip
• The relevant call is: com.dynamicg.timerecinfogetter.TimeRecDataGetter.getData()

DATA_EXPORT
Report generation can be triggered through broadcast intent. Sample see below.

What's Check in vs. Punch vs. Start new task
• 'Check in' will check in once. Repeated calls are ignored
• 'Punch' will do a check in or a check out, depending on the current state.
• 'Start new task' performs a "check in" to start a new work unit. If you have been checked in already, the previous work unit is closed with a "check out".

GET_TASKS
This is for developers who want to read the task list. Also see "Tasks export/import". Intent intent = new Intent("com.dynamicg.timerecording.GET_TASKS"); intent.setPackage(getTimeRecPackage(context)); BroadcastReceiver resultReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent resultIntent) { Bundle extras = this.getResultExtras(true); if (extras!=null) { ArrayList<Integer> taskIds = extras.getIntegerArrayList("com.dynamicg.timerecording.GET_TASKS.IDS"); String[] taskNames = extras.getStringArray("com.dynamicg.timerecording.GET_TASKS.NAMES"); String[] clientNames = extras.getStringArray("com.dynamicg.timerecording.GET_TASKS.CLIENTS"); String[] extra1 = extras.getStringArray("com.dynamicg.timerecording.GET_TASKS.EXTRA1"); String[] extra2 = extras.getStringArray("com.dynamicg.timerecording.GET_TASKS.EXTRA2"); boolean currentlyCheckedIn = extras.getBoolean("com.dynamicg.timerecording.GET_TASKS.STATE_CHECKED_IN"); int currentTaskId = extras.getInt("com.dynamicg.timerecording.GET_TASKS.STATE_TASK_ID"); } } }; context.sendOrderedBroadcast(intent, null, resultReceiver, null, Activity.RESULT_OK, null, null);
UPDATE_STAMP_VALUE
• This updates one of the "Value" fields
• Broadcast receiver: com.dynamicg.timerecording.SERVICE_DISPATCHER with OPERATION=STAMP_VALUE_UPDATE
• Bundle values: key={VALUE_1|VALUE_2|VALUE_A|VALUE_B|VALUE_C|VALUE_D}, value={the value you want to set}
• By default, the current work unit is updated. Optional bundle value: key=TIME, value=time stamp in format hh24:mm of the work unit you want to update.
• Sample: Intent intent = new Intent("com.dynamicg.timerecording.SERVICE_DISPATCHER"); intent.setPackage(getTimeRecPackage(context)); intent.putExtra("OPERATION", "UPDATE_STAMP_VALUE"); intent.putExtra("VALUE_A", "TestA_"+new java.util.Date()); intent.putExtra("TIME", "08:46"); context.sendBroadcast(intent);
DATA_EXPORT example
final String dateFrom = "2017-08-01"; // format "yyyy-mm-yy" final String dateTo = "2017-08-31"; // format "yyyy-mm-yy" final String exportType = "e3"; // "e2" to "e10" final String exportFormat = "html"; // values [html, xls, pdf, csv, xml] Intent intent = new Intent("com.dynamicg.timerecording.DATA_EXPORT"); intent.setPackage(getTimeRecPackage(context)); intent.putExtra("com.dynamicg.timerecording.DATE_FROM", dateFrom); intent.putExtra("com.dynamicg.timerecording.DATE_TO", dateTo); intent.putExtra("com.dynamicg.timerecording.EXPORT_TYPE", exportType); intent.putExtra("com.dynamicg.timerecording.EXPORT_FORMAT", exportFormat); // provide your package name so that TimeRec can grant the file uri: intent.putExtra("com.dynamicg.timerecording.CALLED_BY_PKG", context.getPackageName()); // ALTERNATIVELY: PASS ALL PARAMS WITH ONE SINGLE "EXTRA" //String exportData = dateFrom+","+dateTo+","+exportType+","+exportFormat; //intent.putExtra("com.dynamicg.timerecording.EXPORT_DATA", exportData); BroadcastReceiver resultReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent resultIntent) { Bundle bundle = this.getResultExtras(true); // ** deprecated, based on direct file access; this works on devices up to Android 10 //String filepath = bundle.getString("com.dynamicg.timerecording.FILE"); //File file = new File(filepath); //String feedback = "File=["+file+"], canRead=["+file.canRead()+"]"; //Toast.makeText(context, feedback, Toast.LENGTH_LONG).show(); //System.err.println(feedback); // ** starting with Time Recording 7.50 Beta 2 we're returning the file's android.net.Uri // ** caution: this strictly required passing your package in "com.dynamicg.timerecording.CALLED_BY_PKG" above String uristring = bundle.getString("com.dynamicg.timerecording.FILE_URI"); android.net.Uri uri = android.net.Uri.parse(uristring); Toast.makeText(context, "uri: "+uri.toString(), Toast.LENGTH_SHORT).show(); // content can be accessed via the uri's input stream, like so: // InputStream is = context.getContentResolver().openInputStream(uri); } }; context.sendOrderedBroadcast(intent, null, resultReceiver, null, Activity.RESULT_OK, null, null);