Android Open Source - android-textlater Alarm Receiver






From Project

Back to project page android-textlater.

License

The source code is released under:

Apache License

If you think the Android project android-textlater listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2013 The Android Open Source Project
 *//from  w ww .ja  v  a  2  s. c om
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.michael.feng.textlater;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class AlarmReceiver extends BroadcastReceiver {

  String textContact = "";
  String textNumber = "";
  String textWhen = "";
  String textContent = "";
  MessageDAO messageDAO = null;

  @Override
  public void onReceive(Context context, Intent intent) {

    // Intent must add Intent.FLAG_ACTIVITY_NEW_TASK flag
    Intent in = new Intent(context, SendActivity.class);
    in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (intent.hasExtra("textContact")) {
      textContact = intent.getStringExtra("textContact");
      in.putExtra("textContact", textContact);
    }
    if (intent.hasExtra("textNumber")) {
      textNumber = intent.getStringExtra("textNumber");
      in.putExtra("textNumber", textNumber);
    }
    if (intent.hasExtra("textWhen")) {
      textWhen = intent.getStringExtra("textWhen");
      in.putExtra("textWhen", textWhen);
    }
    if (intent.hasExtra("textContent")) {
      textContent = intent.getStringExtra("textContent");
      in.putExtra("textContent", textContent);
    }

    if (!"".equals(textWhen) && !"".equals(textContact) && !"".equals(textContent)) {

      messageDAO = new MessageDAO(context);
      messageDAO.open();

      // 1 - hasSent, 0 - not sent default value
      messageDAO.updateMessageStatus(textContact, textWhen, "1");
      messageDAO.close();

    }
    context.startActivity(in);
  }

}




Java Source Code List

com.michael.feng.textlater.AlarmReceiver.java
com.michael.feng.textlater.ContactsActivity.java
com.michael.feng.textlater.DetailActivity.java
com.michael.feng.textlater.MainActivity.java
com.michael.feng.textlater.MessageDAO.java
com.michael.feng.textlater.Message.java
com.michael.feng.textlater.NewActivity.java
com.michael.feng.textlater.SQLiteHelper.java
com.michael.feng.textlater.SendActivity.java