Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Identifying the device type in MIDlets

 
varsha gaware
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Liam Quinn
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic