This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes How to get network information? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "How to get network information?" Watch "How to get network information?" New topic
Author

How to get network information?

Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 199
Hi Ranchers,


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.


Thanks and Regards

Girish Vasmatkar
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15961
    
  19

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.
Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 199
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.

Thanks and Regards
Girish Vasmatkar
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15961
    
  19

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get network information?
 
Similar Threads
Serializing Vector
Vectors
vector and resultset
can you have an array of vectors
Tomcat Window Authentication