01-06-2009 06:41 AM
I have a java program that uses a HttpConnection (in the main thread). It works absolutely fine on the simulator but when I run it on my device (8310 Curve), it just do nothing ! Even after asking to allow the application make http connections.
I hear about some APN settings to be configured on device. I did that too ("airtelgprs.com" with username/password blank for Airtel, India).
Is there something else that is not letting my application establish http connections ? Can someone please tell me what all do I need to do tomake my http connections work on device ?
Solved! Go to Solution.
01-06-2009 07:08 AM
I presume that you have reviewed:
What Is - Different ways to make an HTTP or socket connection
Article Number: DB-00396
So you will understand that there are a variety of ways that the connection can be made on a real device, and these might be different to a simulator.
You say that you connect in the Main Thread. Do you mean the Event Thread - i.e. the same Thread that is run as a result of screen interaction? If so, this may work on the simulator, but will not work on the device for two reasons:
a) The device may attempt to seek authorization from your user via a 'Firewall' popup dialog - this can't be displayed while you won the Event Thread
b) The I/O is blocking, so will effectively prevent all User Interaction on the Device.
If this is not what you are doing, I would debug on the device and see where the problem is occurring and what Exception is being thrown.
I presume you are based in India and trying to use the India airtel service. many people seem to have reported problems with this. Search this forum for airtel and have a look.
Hope this helps.
01-06-2009 08:00 AM
Hey thanks dave !
But it didnt work out either. I tried debugging it and got the following error :
"blocking operation not permitted on event dispatch thread". Has anyone any idea what it is all about ?
01-06-2009 08:13 AM
That means that you cannot perform a blocking IO operation, like an HTTP connection, from the event handling thread in your program. You must create a worker thread to handle the HTTP connection activities.
01-07-2009 12:01 AM
Thanks Peter & Rex !
Okay so I need to perform my http connections in a seperate thread. But I have an issue with the threads as well, I am not able to figure out how to stop / kill a thread ?
I am using JDE 4.2.1 and I can't see any method to kill a thread.
01-08-2009 03:25 PM
01-09-2009 12:19 AM
Thanks Mark !
I now have a couple of more questions:
I would really be greatful for any help on this.
01-09-2009 01:01 AM
1.I have tried to cancel during download by using interrupt method.The thread had stopped,but problem is that,it continues to download in the background until the end although all objects were null.
2.use repaint/rellayout method of UIApplication.But placed it in synchronized(uiApp.getAppEventlock()).where uiApp is object of UIApplication.Because the process is in separate thread and u have to require the event lock of current application.