안녕하세요. 작업 알리미 응용 프로그램을 만들었습니다. 그러나 작업 이름을 사용하여 작업을 사용자에게 알릴 수는 없습니다. 그것은 상당히 간단한 일이지만, 나는 그것을 할 수 없습니다.Android 애플리케이션 도움말
내가 원하는 것은 : "Task 3"이라는 작업을 저장하고 오후 6시를 생각 나게합니다. 오후 6시에 "작업 3"이라는 알림 알림이 표시됩니다. 현재 "작업을 검토해야합니다"라는 메시지 만 표시됩니다. 작업 제목을 검색하여 문자열 대신 알림으로 표시하는 방법이 있습니까?
이
는 알림 서비스 클래스 클래스입니다 :공공 ReminderService() { 슈퍼 ("ReminderService"); }
@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);
//이 부분은 변경해야합니다.
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);
는이 내가 제대로 이해하고, 문제가 당신이 당신의 string.xml에 정의 된 상수 문자열을 표시한다는 것이다 remindersadapter 클래스
* @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) > 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) > 0;
}
}
안녕하시오. 나는 행 ID를 사용하여 시도했지만, 어떤 이유로 그것은 제목 "id"를 보여주지 않을 것이다. – Superunknown
내 대답은 위의 내 대답을 참조하십시오. – Moystard
안녕하세요. String ReminderTitle = cursor.getString (cursor.getColumnIndex (RemindersDbAdapter.KEY_TITLE)); fetchreminder 메소드 내부로 이동 하시겠습니까? – Superunknown