liyuanwei / imsdroid

Automatically exported from code.google.com/p/imsdroid
0 stars 0 forks source link

How to send plain text messages without fancy UI stuff? #185

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. When in-call I would like to send a text message say "Hello" when I hit a 
menu button
2. The following is the code I added in the newly created menu button

final MySipStack sipStack = ServiceManager.getSipService().getStack();
String myText = "Hello";
byte[] content = myText.getBytes();
boolean success = false;
final MessagingSession session = new MessagingSession(sipStack);
if(sipStack.getSigCompId() != null){
    session.addSigCompCompartment(sipStack.getSigCompId());
}
session.setToUri(validUri);
session.addHeader("Content-Type", "text/plain");

final ByteBuffer payload = ByteBuffer.allocateDirect(content.length);
payload.put(content);
success = session.send(payload, content.length);
if(success){
    Toast.makeText(getApplicationContext(), "Message Sent", Toast.LENGTH_SHORT).show();
}
else{
    Toast.makeText(getApplicationContext(), "Message Failed", Toast.LENGTH_SHORT).show();
}
session.delete();

3. For now in the OnMessagingEvent(MessagingEvent e) in the SipService.java I 
have added the following debug code to determine that I received a plain text 
message. Later I will do some manipulation to the text received.
.
case tsip_i_message:
   ....
   ....
   else{
    /* ==== text/plain or any other  === */
    content = bytes;
    Log.d(SipService.TAG, "Received text/plain message");
}

What is the expected output? What do you see instead?
I expect that the message is sent and received without any UI activity like 
accept/cancel etc. Please let me know if the above approach will work?

What version of the product are you using? On what operating system?
IMSDroid/v1.2.353 (doubango r539) on Android 2.2

Please provide any additional information below.

Original issue reported on code.google.com by kow...@gmail.com on 22 Feb 2011 at 6:00

GoogleCodeExporter commented 9 years ago
What do you mean by "without fancy UI stuff"?

Original comment by boss...@yahoo.fr on 28 Feb 2011 at 9:12

GoogleCodeExporter commented 9 years ago
I just meant without any progress bar and accept/reject kind of interfaces. 
This should happen in the back ground without any user interaction.

Original comment by kow...@gmail.com on 1 Mar 2011 at 5:26

GoogleCodeExporter commented 9 years ago
Hi,I have the same issue

Original comment by sundl2...@gmail.com on 1 Mar 2011 at 6:18

GoogleCodeExporter commented 9 years ago

Original comment by boss...@yahoo.fr on 7 Aug 2011 at 4:13