SMS conversation

I am developing an SMS application. I can send and receive SMS.

I have a tab called Inbox. When you click on it, I show all conversations using the URI content://mms-sms/conversations/ .

When I click on any conversation, I want to show all SMS messages between this person and me.

I received all messages of this person from URI content://sms/inbox , and my messages to this user from URI content://sms/sent .

Now, how can I show these messages in the user list view so that my messages have the prefix "I" and other messages have the prefix "<name / number>" and are ordered according to date and time?

+4
source share
1 answer

I am trying to do something like this. Have you decided this? I think I have to do it manually! I think that use the phone number as a login (not all companies store the number on the phone), and then compare the message number with the registered number. On the layout you can have something like this:

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:weightSum="1.0" > <TextView android:id="@+id/txtMessageDate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginBottom="5dip" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:layout_marginTop="10dip" android:maxWidth="250dip"/> <TextView android:id="@+id/txtMessageRight" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/righttext" android:layout_marginLeft="16dp" android:maxWidth="250dip" /> <TextView android:id="@+id/txtMessageLeft" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_marginLeft="37dp" android:layout_toRightOf="@+id/lefttext" android:maxWidth="250dip"/> </RelativeLayout> 

Write down the number that you can find out if the number, if from your number or from another number of the party, so in the code you can inflate the layout and using "if" you can write your name or the name of the contact. Something like this:

 if(o.getOriginatingAddress().equals(MainActivity.loggedNumber)) tvOutMessage.setText("me: " + o.getMessageBody()); else tvInMessage.setText("contact:" + o.getMessageBody()); 

I do not know if this is the best solution, but I hope this helps.

0
source

All Articles