• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

j2me/ksoap error

 
kishani liyanage
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
>
> I'm new to J2ME and KSOAP, i downloaded libraries and sample from "kSOAP Download section" but they don't work!
> I copied ksoap-midp.zip and kxml2.zip (rename in .jar) to "lib" application directory, i compiled and ran the project, and when the application send the request, it stops work! Ktoolbar return the warning:
>
> Warning: To avoid potential deadlock, operations that may block, such as
> networking, should be performed in a different thread than the
> commandAction() handler.
>
> I tried StockQuoteDemo and CashConv.I use j2me 2.0. Please can someone give me a solution to this.
Thanks in advance.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to put network operations in a separate thread. You can start the thread from the "commandAction()" method.
 
Ould Nadif
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I agree with Michael.
Here a code to help you to create your thread:
if(command==ActionCommandxxx){


Thread t = new Thread() {
public void run() {
//open connecttion

};

//On lance le thread
t.start();

}
 
kishani liyanage
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a beginner at j2me. Please if u could explain a little bit further on how i could do the network operation in a different thread and how i could start the thread from the "commandAction()" method i would be much grateful to u. Thanx a lot!
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think OULD has give you the exact code you need? If you want to see a complete example, check out an example MIDlet I had in the appendix of my book:
http://www.enterprisej2me.com/pages/enterprisej2me/codebrowser.php?req=//appendix01/SimpleDemo/src/com/enterprisej2me/simpledemo/DemoMIDlet.html
Also, I deleted your duplicated posts.
cheers
Michael
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic