I´ve been using the code provided by the emulator to use Gtalk service. It has two files: GtalkDataMessageSender and GTalkDataMessageReceiver.
I have changed both of them to get a chat-looking interface. What i want is to write the message and show it in the screen, and when other user sends a message to me, i want this message to be shown in the screen as well.
The problem is that no message is ever shown to me. I have debugged many times and no error seems to be. I put here the code , maybe someone sees what i am doing wrong:
Send the text message:
Using java Syntax Highlighting
- ...
- } else if (view == mSend) {
- // use XmppService to send data message to someone
- themessage=mSendText.getText().toString();
- String username = mRecipient.getText().toString();
- if (!isValidUsername(username)) {
- showMessage(getText(R.string.invalid_username));
- return;
- }
- if (mGTalkSession == null) {
- showMessage(getText(R.string.gtalk_service_not_connected));
- return;
- }
- try {
- mGTalkSession.sendDataMessage(username, getIntentToSend());
- } catch (DeadObjectException ex) {
- Log.e(LOG_TAG, "caught " + ex);
- showMessage(getText(R.string.found_stale_gtalk_service));
- mGTalkSession = null;
- bindGTalkService();
- }
- }
- }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
to view in the screen
Using java Syntax Highlighting
- Cursor cursor = managedQuery(Im.Messages.CONTENT_URI, null,
- null, null, null);
- // Display the cursor results in a simple list
- // Note that the adapter is dyamic (picks up new entries automatically)
- SimpleCursorAdapter adapter =
- new SimpleCursorAdapter(this, R.layout.textview1, cursor, new String[]{Im.MessagesColumns.BODY}, new int[]{R.id.text1});
- setListAdapter(adapter);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
and the xml file:
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- >
- <EditText android:id="@+id/recipient"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textSize="16sp"
- android:minWidth="250dp"
- android:autoText="false"
- android:capitalize="none"
- android:scrollHorizontally="true"/>
- <Button android:id="@+id/setup"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Setup">
- <requestFocus/>
- </Button>
- </LinearLayout>
- <ListView android:id="@id/android:list"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:drawSelectorOnTop="false"/>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- >
- <EditText android:id="@+id/sendText"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textSize="16sp"
- android:minWidth="250dp"
- android:autoText="false"
- android:capitalize="none"
- android:scrollHorizontally="true"/>
- <Button android:id="@+id/send"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Send">
- <requestFocus/>
- </Button>
- </LinearLayout>
- </LinearLayout>
Parsed in 0.008 seconds, using GeSHi 1.0.8.4
Thanks!!

