aspose file tools*
The moose likes Java Micro Edition and the fly likes Identifying the device type in MIDlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Identifying the device type in MIDlets" Watch "Identifying the device type in MIDlets" New topic
Author

Identifying the device type in MIDlets

varsha gaware
Greenhorn

Joined: Jul 04, 2003
Posts: 2
I want to find out a device type/model/name on which my MIDLet is running. For E.g. BlackBerry or PalmOS etc. Is there any way of doing it ?
Pearlo Muthukumaran
Ranch Hand

Joined: Sep 17, 2002
Posts: 79
Hi Varsha,
There is one way of doing this. Add a functionality to your MIdlet to perform a HTTP Request to the server(HTTP Get or POST). HTTP Header - User Agent Field will contain the Model and Make of the Device.This can be trapped by the receiver servlet / JSP. If the device supports UAProf then it will contain other capabilities information also.
Rgds
Muthu
David Price
Ranch Hand

Joined: Jan 22, 2003
Posts: 93
You should be able to find out the device type by calling in your MIDlet. Most devices will return a String describing the device (e.g. my Nokia 7210 returns "Nokia7210/4.20").
Unfortunately, not all devices implement this properly - some just return null, others just return "j2me". I don't know about Palm or Blackberry.
Fred Grott
Ranch Hand

Joined: Oct 05, 2002
Posts: 346
Originally posted by David Price:
You should be able to find out the device type by calling in your MIDlet. Most devices will return a String describing the device (e.g. my Nokia 7210 returns "Nokia7210/4.20").
Unfortunately, not all devices implement this properly - some just return null, others just return "j2me". I don't know about Palm or Blackberry.

David what devices don't implement this? I though all MIDP1.0 compliant devices had to implement this ?


MobileBytes blog - Sharing Technology - My Programming Knols
Liam Quinn
Ranch Hand

Joined: Jan 18, 2002
Posts: 35
Motorola and Sony Ericsson phones return null for microedition.platform. Sanyo, Samsung, LG, and MIDP4Palm all return "j2me".
Most phones do not set a User-Agent header with MIDP HttpConnections, so you can't rely on that either.
When I've needed to identify the device, I've used a combination of microedition.platform, the canvas size, and the number of display colours. Unfortunately, it involves some guesswork and isn't very robust, but I've found it satisfactory for my needs.
varsha gaware
Greenhorn

Joined: Jul 04, 2003
Posts: 2
Hello all,
thanks for your replies..
Finally I did something like this, which returns true on plam and false on blackberry ..
boolean bIsPalm;
Class.forName("com.sun.midp.palm.Info");
bIsPalm = true;
Thanks,
varsha
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Identifying the device type in MIDlets