Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Application Help
    primarykey
    data
    text
    <p>Hi I have created a task reminder application. However I am unable to get it to notify the user of the task with the task name. It should be a fairly simple thing to do, but I am unable to do it. </p> <p>What I want it to do is: I save a task called "Task 3" and to remind me for 6pm. When 6pm comes, I get a notification alert saying "Task 3". At the moment, it only says "task needs to be reviewed" Is there a way of retrieving the task title and presenting it as a notification instead of a string?</p> <p>This is the reminder service class class:</p> <p>public ReminderService() { super("ReminderService"); }</p> <pre><code>@Override void doReminderWork(Intent intent) { Log.d("ReminderService", "Doing work."); Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID); NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(this, ReminderEditActivity.class); notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId); PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT); </code></pre> <p>//This is the bit I need to change by the way.</p> <pre><code> Notification notification=new Notification(android.R.drawable.stat_sys_warning, getString(R.string.notify_new_task_message), System.currentTimeMillis()); notification.setLatestEventInfo(this, getString(R.string.notify_new_task_title), getString(R.string.notify_new_task_message), pi); </code></pre> <p>and this is the remindersadapter class </p> <pre><code>* @param reminderDateTime the date and time the reminder should remind the user * @return rowId or -1 if failed */ public long createReminder(String title, String body, String reminderDateTime) { ContentValues initialValues = new ContentValues(); initialValues.put(KEY_TITLE, title); initialValues.put(KEY_BODY, body); initialValues.put(KEY_DATE_TIME, reminderDateTime); return mDb.insert(DATABASE_TABLE, null, initialValues); } /** * Delete the reminder with the given rowId * * @param rowId id of reminder to delete * @return true if deleted, false otherwise */ public boolean deleteReminder(long rowId) { return mDb.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) &gt; 0; } /** * Return a Cursor over the list of all reminders in the database * * @return Cursor over all reminders */ public Cursor fetchAllReminders() { return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_DATE_TIME}, null, null, null, null, null); } /** * Return a Cursor positioned at the reminder that matches the given rowId * * @param rowId id of reminder to retrieve * @return Cursor positioned to matching reminder, if found * @throws SQLException if reminder could not be found/retrieved */ public Cursor fetchReminder(long rowId) throws SQLException { Cursor mCursor = mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_BODY, KEY_DATE_TIME}, KEY_ROWID + "=" + rowId, null, null, null, null, null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; } /** * Update the reminder using the details provided. The reminder to be updated is * specified using the rowId, and it is altered to use the title, body and reminder date time * values passed in * * @param rowId id of reminder to update * @param title value to set reminder title to * @param body value to set reminder body to * @param reminderDateTime value to set the reminder time. * @return true if the reminder was successfully updated, false otherwise */ public boolean updateReminder(long rowId, String title, String body, String reminderDateTime) { ContentValues args = new ContentValues(); args.put(KEY_TITLE, title); args.put(KEY_BODY, body); args.put(KEY_DATE_TIME, reminderDateTime); return mDb.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) &gt; 0; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload