Android - 如何显示过期日期并在过期时通知用户

时间:2014-01-07 19:13:29

标签: android notifications

我目前正在创建一个Android应用程序来通过记录系统管理作业应用程序,类似于联系人应用程序或地址簿。在主屏幕上,用户可以通过右上角的“添加”按钮查看他们创建的记录列表。通常,显示的记录列表只显示作业标题,作为记录的标题(即销售助理)。 但是,用户在创建记录时输入的标准之一是他们的访谈日期。

我想这样做,以便记录列表不仅显示作业标题,还显示到期日期。很简单,只需要用户输入的日期,以及在设备上注册的当前日期。除了在设备上弹出通知之外,我不知道如何检索这些内容,或者如何显示用户已过期的日期。

我还使用SQLite存储用户在制作记录时输入的各种信息,并使用Eclipse创建我的应用程序。

XML中的

:     `

    <TextView
        android:id="@+id/interviewDateTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:paddingLeft="@dimen/padding_9dp"
        android:text="@string/interview_date"
        android:textSize="@dimen/padding_9dp" />

    <EditText
        android:id="@+id/InterviewDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="10"
        android:inputType="date"
        android:paddingRight="@dimen/padding_9dp" >
    </EditText>
</TableRow>`
SQL查询中的

"CREATE TABLE records ( recordId INTEGER PRIMARY KEY, jobTitle TEXT, " + "jobDescription TEXT, contactNumber TEXT, emailAddress TEXT, contactName TEXT, applicationDate DATE, interview TEXT, " + "interviewDate DATE, methodApplied TEXT, companyName TEXT)"

在相关的.java文件中,

public void addNewRecord(View view) {

    // Will hold the HashMap of values 

    HashMap<String, String> queryValuesMap =  new  HashMap<String, String>();

    // Get the values from the EditText boxes

    queryValuesMap.put("jobTitle", jobTitle.getText().toString());
    queryValuesMap.put("jobDescription", jobDescription.getText().toString());
    queryValuesMap.put("contactName", contactName.getText().toString());
    queryValuesMap.put("emailAddress", emailAddress.getText().toString());
    queryValuesMap.put("contactNumber", contactNumber.getText().toString());
    queryValuesMap.put("methodApplied", methodApplied.getText().toString());
    queryValuesMap.put("interview", interview.getText().toString());
    queryValuesMap.put("interviewDate", interviewDate.getText().toString());
    queryValuesMap.put("companyName", companyName.getText().toString());
    queryValuesMap.put("applicationDate", applicationDate.getText().toString());
    // Call for the HashMap to be added to the database

    dbTools.insertRecord(queryValuesMap);

    this.callMainActivity(view);
}

我基本上需要比较日期;如果当前日期等于用户对任何记录的访问日期,那么我想打电话通知他们今天的访谈是为了该记录(即'警告:你今天有一份工作面试[jobTitle] “)。我可以创建通知等等,它只是提取并比较我遇到问题的日期。

1 个答案:

答案 0 :(得分:0)

要获取当前时间,请使用:

long curTime = Calendar.getInstance().getTimeInMillis();

用户输入采访日期的格式是什么?