Android Open Source - CloudyPhone Sms Manager






From Project

Back to project page CloudyPhone.

License

The source code is released under:

MIT License

If you think the Android project CloudyPhone 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

package com.cloudyphone.android.model.sms;
/*from   ww  w.j  a v  a 2s .c  om*/
import java.util.TreeMap;

import org.json.JSONArray;

import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;

public class SmsManager {

  private static final Uri SMS_CONTENT_URI = Uri.parse("content://sms/");

  public static ParseSmsThreads getSmsThreads(ContentResolver cr) {

    TreeMap<Long, JSONSmsThread> threads = new TreeMap<Long, JSONSmsThread>();

    Cursor cursor = cr.query(SMS_CONTENT_URI, new String[] { "_id",
        "thread_id", "address", "date", "body", "type" }, null, null,
        null);

    long threadId, messageId, date, type;
    String phoneNumber, body;
    JSONSmsThread t;
    JSONArray messages;

    while (cursor.moveToNext()) {
      threadId = cursor.getLong(1);

      if (!threads.containsKey(threadId)) {
        phoneNumber = cursor.getString(2);

        /* thread does not exist, create one */
        threads.put(threadId, new JSONSmsThread(threadId, phoneNumber,
            new JSONArray()));
      }

      /* get the thread with that ID and messages in that thread */
      t = threads.get(threadId);
      messages = t.getMessages();

      // get information
      messageId = cursor.getLong(0);
      date = cursor.getLong(3);
      body = cursor.getString(4);
      type = cursor.getLong(5);

      // put the new message to messages list of the thread
      messages.put(new JSONSmsMessage(messageId, date, body, type));
    }

    cursor.close();

    return new ParseSmsThreads(new JSONArray(threads.values()));
  }
}




Java Source Code List

com.cloudyphone.android.Constants.java
com.cloudyphone.android.controller.activities.CloudyPhoneActivity.java
com.cloudyphone.android.controller.activities.LoginActivity.java
com.cloudyphone.android.controller.activities.ResetPasswordActivity.java
com.cloudyphone.android.controller.activities.SignupActivity.java
com.cloudyphone.android.controller.activities.WelcomeActivity.java
com.cloudyphone.android.controller.callbacks.MyLoginCallback.java
com.cloudyphone.android.controller.callbacks.MyResetPasswordCallback.java
com.cloudyphone.android.controller.callbacks.MySignUpCallback.java
com.cloudyphone.android.controller.commands.Command.java
com.cloudyphone.android.controller.commands.CommandsAsyncTask.java
com.cloudyphone.android.controller.commands.SyncContactsCommand.java
com.cloudyphone.android.controller.commands.SyncContactsImagesCommand.java
com.cloudyphone.android.controller.commands.SyncPhoneInforCommand.java
com.cloudyphone.android.controller.commands.SyncSmsThreadsCommand.java
com.cloudyphone.android.controller.listeners.LoginClickListener.java
com.cloudyphone.android.controller.listeners.ResetPasswordClickListener.java
com.cloudyphone.android.controller.listeners.SignupClickListener.java
com.cloudyphone.android.controller.network.ServerConnector.java
com.cloudyphone.android.controller.push.PushManager.java
com.cloudyphone.android.controller.receivers.CopyClipboardReceiver.java
com.cloudyphone.android.controller.receivers.DenyCallReceiver.java
com.cloudyphone.android.controller.receivers.MakeCallReceiver.java
com.cloudyphone.android.controller.receivers.OpenWebReceiver.java
com.cloudyphone.android.controller.receivers.PushReceiver.java
com.cloudyphone.android.controller.receivers.SendSmsReceiver.java
com.cloudyphone.android.controller.receivers.SyncReceiver.java
com.cloudyphone.android.controller.sync.SyncThread.java
com.cloudyphone.android.controller.sync.UpdateThread.java
com.cloudyphone.android.model.InputValidator.java
com.cloudyphone.android.model.MyParseObject.java
com.cloudyphone.android.model.contact.ContactsManager.java
com.cloudyphone.android.model.contact.JSONContact.java
com.cloudyphone.android.model.contact.ParseContactImg.java
com.cloudyphone.android.model.contact.ParseContacts.java
com.cloudyphone.android.model.infor.ParsePhoneInfor.java
com.cloudyphone.android.model.sms.JSONSmsMessage.java
com.cloudyphone.android.model.sms.JSONSmsThread.java
com.cloudyphone.android.model.sms.ParseSmsThreads.java
com.cloudyphone.android.model.sms.SmsManager.java
com.cloudyphone.android.utils.Logger.java