Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
Posts: 39
Registered: ‎09-29-2009
My Device: Curve 8330
My Carrier: Verizon
Accepted Solution

Blackberry Browser not seen as Handheld?

I am trying to develop a simple asp.net web app for the BlackBerry that I also want to use in the "PC World".  The main thing is that if it's a BlackBerry browser, I want it to use smaller fonts.  If it's a PC version, I want it to use larger fonts.  This seems like a job for CSS with media indicators.  I've tried all sorts of things, and the BB browser does not seem to be presenting itself to the app as a Handheld.  So, is there another way, other than the media indicator to determine this?  Or is there a way to get BB to present itself as a Handheld?

 

I am hand-coding this app.  I have the free version of VS installed, and the BB Widgets app won't work with that.  I don't have the money to spend on a full VS version right now, so I'm sticking with hand-coding.

 

I am some-what of an "infant" regarding CSS and how it works, so if someone can "hold my hand" on this, I would appreciate it.

 

Thanks,

Jesse

Developer
Posts: 168
Registered: ‎11-01-2008
My Device: Galaxy S II
My Carrier: Meteor (Ireland)

Re: Blackberry Browser not seen as Handheld?

BlackBerry screens have a very high dpi compared to PC screens (e.g. Storm is 184 dpi) so one way to select the appropriate font is to use the 'min-resolution' media selector, e.g.

 

body, html
{
	font-size: [whatever is appropriate for PC];
}

@media all and (min-resolution: 175dpi)
{
	body, html
	{
		font-size: [whatever is appropriate for BlackBerry];
	}
}

Incidentally, are you specifying font sizes using pt or px? The reason I ask is that if you use px then you'll find that on devices with a very high dpi you actually have to use a larger font than on the PC if you want it to be legible.

 

 

New Developer
Posts: 39
Registered: ‎09-29-2009
My Device: Curve 8330
My Carrier: Verizon

Re: Blackberry Browser not seen as Handheld?

Excellent.  I didn't think of doing it that way. I found another way using JavaScript and the navigator.appVersion, which contains the word "BlackBerry" in it, but your way is cleaner.

 

I am using pt's, not px's for the font-size.

 

Thanks for the help.

 

Jesse

Developer
Posts: 168
Registered: ‎11-01-2008
My Device: Galaxy S II
My Carrier: Meteor (Ireland)

Re: Blackberry Browser not seen as Handheld?

No worries. Be sure to mark the thread as solved and give kudos if you feel it's deserved Smiley Happy

Developer
Posts: 107
Registered: ‎09-25-2008
My Device: Not Specified

Re: Blackberry Browser not seen as Handheld?

I believe most browsers now (including the BlackBerry browser) assume a 96 dpi screen, even if the actual dpi is different. This is done for backwards compatibility with websites that look all messed up if anything else is used. All the pt calculations are done with 96dpi.

Developer
Posts: 168
Registered: ‎11-01-2008
My Device: Galaxy S II
My Carrier: Meteor (Ireland)

Re: Blackberry Browser not seen as Handheld?

On most desktop/laptop systems the dpi is logical not physical. However, on the BlackBerry and many other mobile platforms the dpi is actually meaningful. By extension, the point size is also meaningful, i.e. 10pt means 10 * (1/72) physical inches. You can specify fonts based on point size therefore and be reasonably confident that text will have the same physical size on different screens.

 

If you try the media selector I've shown above you'll see that the Storm comes in at exactly 184dpi. Combine "min-resolution: 184" with "max-resolution: 185" and you'll see that it'll match it exactly.

Developer
Posts: 168
Registered: ‎11-01-2008
My Device: Galaxy S II
My Carrier: Meteor (Ireland)

Re: Blackberry Browser not seen as Handheld?

In relation to the Storm's dpi, I should have justified that with figures...

 

  • The Storm is 360x480 px.
  • This works out at 600 px in the diagonal when you use Pythagoras.
  • The screen measures 3.26" in the diagonal.
  • Dividing the first figure by the second yields 184 dpi.

 

Highlighted
Developer
Posts: 107
Registered: ‎09-25-2008
My Device: Not Specified

Re: Blackberry Browser not seen as Handheld?

I agree that the actual screen resolution is 184 dpi, and that the media queries use that. However, if you create a page with this HTML:

 

  <style>
   div { border: solid 1px; }
  </style>
  <div style="width:96px">blah</div>
  <div style="width:72pt">bloo</div>

 The boxes will appear the same width, even though that should only happen on 96dpi devices. The point-to-pixel conversion is the algorithm that pretends the screen's dpi is 96.

Developer
Posts: 168
Registered: ‎11-01-2008
My Device: Galaxy S II
My Carrier: Meteor (Ireland)

Re: Blackberry Browser not seen as Handheld?

 

I've just tried that out - crazy stuff! Makes no difference to me because I always set font-size using px instead of pt. But that's very good to know. Thanks.