×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    1

    httpconnection and SMS messageconnection (J2ME)

    Friends,

    HttpConnection hc = null;

    InputStream in = null;

    hc = (HttpConnection)Connector.open("www.google.com");

    in = hc.openInputStream();;


    ----etc etc etc to read the inputstream


    2. Next i create an SMS connection.

    String ToPhone = "sms://123456789";

    MessageConnection smsconn = null;

    smsconn = (MessageConnection)Connector.open(ToPhone);

    TextMessage txtmessage =
    (TextMessage)smsconn.newMessage(MessageConnection.TEXT_MESSAGE);
    txtmessage.setAddress(ToPhone);
    txtmessage.setPayloadText("Hello");
    smsconn.send(txtmessage);

    3. The httpconnection and messageconnections are also properly closed.

    4. Question is -

    I am able to send SMS only for the first time. When I try to run the midlet for the second time, No SMS is received at the destination Phone. and No error / exception is thrown.

    Is it that a midlet or a midlet suite should not have an httpconnection and messageconnection in the same midlet?

    Thanks

    chvravindrakumar
    Hyderabad
    India

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: httpconnection and SMS messageconnection (J2ME)

    Welcome to the Nokia Developer Boards !!

    We can not assume that you closed and reset everything in the code perfectly fine. Other part is that you should not do any operation inside the MIDlet itself except its life cycle handling.

    I will recommend you to make some canvas/ Form which can be launched from the MIDlet and inside this you can make some commands to send the SMS and make the HTTP connection in the different threads. Properly handle the exception and close the HTTP and WMA connection when you are done with the same.

    Go through the web and you will find lots if code samples which make some HTTP connection and SMS operation too. You just need to understand the code and integrate the same in yours.

    Check and revert.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. j2me HttpConnection download fails
    By barbeNoire in forum Mobile Java General
    Replies: 11
    Last Post: 2010-07-26, 07:53
  2. HttpConnection in J2ME + S60
    By arungupta_2jan in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2008-07-26, 20:31
  3. MessageConnection
    By jangv in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2003-04-03, 09:16
  4. Using O2 (UK) GPRS and J2ME HTTPConnection
    By rashley2712 in forum Mobile Java General
    Replies: 0
    Last Post: 2002-12-19, 10:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •