aspose file tools*
The moose likes Java Micro Edition and the fly likes Getting the Screen size of requesting mobile device Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Getting the Screen size of requesting mobile device" Watch "Getting the Screen size of requesting mobile device" New topic
Author

Getting the Screen size of requesting mobile device

pradeep u nair
Greenhorn

Joined: Feb 24, 2006
Posts: 25
hi friends
can anybody tell me how to get the screen size of the mobile device that makes a request for some application on some connected server.Also can the device type be retrieved.
Please help
Pradeep
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
Is JavaScript working for you?


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
pradeep u nair
Greenhorn

Joined: Feb 24, 2006
Posts: 25
hi dema
thnx for your interest in this question.
by the way we are working on the mobile wtk22 emulator.on j2me. i want to get the screen size of the requesting device so that i can place the images i am downloading from a servlet accordingly.
Do you know of any such means.
pls do reply
Pradeep
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
How this device requests? Let's say it uses browser, then you can analyze user agent field, like:
Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)
If your requester is AWT program then you can use:
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
pradeep u nair
Greenhorn

Joined: Feb 24, 2006
Posts: 25
thanks for your answer.i think it works properly.i have to check it with other emulator screens. thnx
Rashid Mayes
Ranch Hand

Joined: Jan 11, 2006
Posts: 160
IS your question specific to J2ME devices? If so, the screen size may not be included in the user agent. You may be able to use the uaprof to determin screen size.

A better solution is for the application to tell the server the dimensions it needs.

You can use the getHeight and getWidth methods of canvas and pass the values to the server via get or post.

i.e. http://myserver/getimage?imageid=x&height=H&width=W

-rashid
www.hostj2me.com


Rashid Mayes
http://www.hostj2me.com/ - http://www.worlddeveloper.org/
pradeep u nair
Greenhorn

Joined: Feb 24, 2006
Posts: 25
hi rasheed
i got the screen size and width with the same methods before itself when dema helped me. i was abt to post it in the reply but thats when i saw your reply.
thnx anyway.
I used a form and the parameters like getWidth and getHeight of the form gave me the correct size of the form and hence the display area.the thing is i tried with an emulator.got to try it with a real phone.
Thnx
Pradeep
Punit Raizada
Ranch Hand

Joined: Mar 20, 2004
Posts: 156
Its great your code is working for you.

Just to categorize a few of the options available.

1) If a MIDlet makes a request to the server, its always better to add a property to the request like screen width and screen height. This way the server can read the HTTP headers of the request and determine what sort of content to send out.

2)A combination of User Agent and/or HTTP_X_WAP_PROFILE (or HTTP_PROFILE) headers can be used by the server to determine the screen dimensions of the mobile device.


SCJP 1.4
Everything that can go wrong will go wrong -Murphy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting the Screen size of requesting mobile device