• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting the Screen size of requesting mobile device

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is JavaScript working for you?
 
pradeep u nair
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your answer.i think it works properly.i have to check it with other emulator screens. thnx
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
pradeep u nair
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic