This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am building an application which requires me to first check if network is available or not.If the network is not available then i need to store the information in a vector and as soon as the network is available the information for the Vector is sent over a GPRS link.My problem is how do i get the network information using J2ME code.
It probably doesn't make much sense to "check if the network is available first". Mobile devices are prone to move in and out of network coverage, so you can potentially start a session only to have it degrade or drop out on you in mid-conversation.
In most cases what I'd do is simply attempt to do the transmission and check the response codes. If the request fails, I'd either display an error or - if appropriate - queue the request up in a daemon task that would retry until the response either worked or was so stale it should be discarded (possibly after notifying the user).
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Apr 24, 2008
Thank you for your reply.But i want a bit more clarification on this.I want to know is how do i code to actually determine whether Network is available since there are different carriers which provide wireless communication. Please pardon me if this question seems to you ridiculous since i am new to J2ME.
It's not just different carriers. My phone uses the same network code to communicate over its WiFi transceiver. In fact, since I'm a cheap <censored>, I don't do network stuff over the phone network right now.
I also have the ability to do TCP/IP networking through my USB data cable. In other words, the phone is just like a desktop computer with multiple Network Interface Cards connecting to different routers. The low-level network code determines which interface will be used for a given transmission and will fall back transparently if that interface goes offline.
Only if all network interfaces are unavailable is the network truly unavailable, although for non-public services, such as talking to a corporate internal webserver, a given service may become unavailable because there's not route to that host.
From the point of view of J2ME, the network API is pretty much the same as for desktop systems. Although since the hardware is more limited, the classes were simplified to keep things more compact.
In the specific case of networking over the telecomm carrier's network, you can treat their service the same way as a dial-up internet link. On my Sprint net that's exactly how they do it, right down to the modem commands.