1. AndroidManifest.xml <activity...> <intent-filter> <action android:name="android.intent.action.VIEW"/> <data android:mimeType="vnd.android.cursor.item/dayup.gtask.task"/> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.INSERT"/> <data android:mimeType="vnd.android.cursor.item/dayup.gtask.task"/> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> < activity> <provider android:name=".GoogleTaskProvider" android:authorities="org.dayup.gtask.googletaskprovider" android:multiprocess="true" android:grantUriPermissions="true" android:readPermission="org.dayup.gtask.permission.READ_TASKS"> </provider> 2. GoogleTaskProvider.java - you can monitor content://org.dayup.gtask.data/tasks for changes. /** * 1. Query for tasklists * uri - content://org.dayup.gtask.data/tasklist * all other params are ignored * * return - all the tasklists, the fields are "ID"(int), "NAME"(string) and "DEFAULT_LIST" (true or false, google tasks has a default task list) * * 2. Query for tasks * uri - content://org.dayup.gtask.data/tasks * projection - ignored * selection - ignored * selectionArgs - the first string should be tasklist id, it should be converted into an integer, ifyou want to get all the tasklists, pass -1 in. * - the second string means with/without completed tasks, if true, the result willinclude completed tasks, otherwise not. * sortOrder - either "DEFAULT" or "DUEDATE", if it is DUEDATE, the result will be sorted by due date. * * return * tasks with fields * ID - the task id, * TITLE - the title of task, * NOTES - the notes of task, * DUEDATE - the due date of task, it will be in long format, as the milliseconds return byDate.getTime * COMPLETED - true of false * LIST_ID - the id of the tasklist which the task belongs to * INDENT - the number of indent of this task, if the sortOder is DUEDATE, this field is always 0.I.E. * TASK A - indent 0 * TASK B - indent 1 * TASK C * TASK D - indent 2 * TASK E * * 3. Query for single task * uri - content://org.dayup.gtask.data/tasks/task_id // task_id is an integer * all other params are ignored * * return - same as "2. Query for tasks" */ @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { 3. .View/Edit task Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(ContentUris.withAppendedId("content://org.dayup.gtask.data/tasks", task_id), "vnd.android.cursor.item/dayup.gtask.task"); 4. New Task Intent intent = new Intent(Intent.ACTION_INSERT); intent.setDataAndType(ContentUris.withAppendedId("content://org.dayup.gtask.data/tasks", task_list_id), "vnd.android.cursor.item/dayup.gtask.task");// If you pass task_list_id as -1, it will add to the default list directly. |