Yet another blog
Friday, December 23, 2011
In my BlackBerry Bengali texts were appearing as boxes. Other phones like iPhone or Android could show Bangla with some issues but at least you could make something out of it. So I was looking for a solution. So did some googling as usual.
The main thing is in order to see Bangla or East Asian language your phone need to have support for East Asian language and font support. And this is not easy to enable. You have to do it with BlackBerry Desktop manager software.
So first install the latest version of BlackBerry Desktop Manager in your pc or mac from here
Then start DM and connect your BB. After your BB is connected with DM you need to install the font support. Click on the Application button on the left panel like shown below
It will load all the applications installed in the device and show you a list of it. Now scroll below and you will see item called "East Asian Characters and Font Support". Click on the left + sign if it is not already expanded.
Here you will see an item called "Indic Characters and Font Support". Beside this item click on the "+" sign to install this item. If already installed it will have the text Installed like mine.
Now click on the Apply button at right bottom and it should start installing the necessary components for you. Give it a some time. Do not disconnect your BB during this time. Your device will reboot. And now you are done. Try to browse for any Bangla web site now.
You should be able to see Bangla now in Facebook app or in web browser. Love to see my language on BB.
Labels: Bangla, Blackberry, view
Tuesday, May 17, 2011
How to use BlackBerry appworld in BlackBerry PlayBook or smartphone?
3 thoughts Written By Shimul at 4:06 PMSaturday, April 17, 2010
Some Useful BlackBerry development tutorials and Custom UI components
1 thoughts Written By Shimul at 9:36 PMLabels: Blackberry, Java
Wednesday, September 30, 2009
How to include external jar file in BlackBerry Eclipse plugin
7 thoughts Written By Shimul at 1:25 PMYou might need to preverify the jar file. This is how you can preverify a jar file
Go to your JDE installation folder, for Windows XP it is usually C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin. If you are using eclipse then you can also find the installation directory of BlackBerry plugin.
2. Copy your jar file to bin folder.
3. Notice the preverify.exe file. This is the tool we'll use.
4. Now open your command prompt and change your current directory to your JDE installation directory.
5. execute the following command:
preverify -classpath "JDE_PATH_HERE\lib\net_rim_api.jar" "your_jar_filename"
6. Notice that in bin directory, another folder named output has been created. Preverified jar file resides here. Copy the preverified jar file with the same name that the non-preverified jar file has.
7. Now replace the non-preverified jar file with the verified one. Use this jar in next steps
Create a new Blackberry project with any name like LibProject.
Right-click on the project and go to Properties.
Go to Blackberry Project Properties. Click on the Application tab.
Under Project Type, change to Library.
Next, go to the Java Build Path.
go to libraries and add the jar file as an external library.
Go to Order and Export tab here, and mark your jar file as exportable
Click OK.
Build the library project.
Now, create your main BlackBerry project
Keep this projects type to as you wish it to be.
Now go to the properties of this project, In the Java Build Path, add the LibProject project as a Project dependency.
You are pretty much ready to import the jar in your code. Try to import a class and see if it works.
Alternatively, what I think that we might skip the first works of creating a new project and try to add the jar directly to our app. I think that might also work. Though I did not try it yet. Let me know if anyone was successful doing it.
That’s all for now
Labels: Blackberry, Eclipse, Java
Saturday, August 8, 2009
System.getProperty("browser.useragent")
Labels: Blackberry
Wednesday, July 22, 2009
public static String unescape(String s)
{
StringBuffer sbuf = new StringBuffer () ;
int l = s.length() ;
int ch = -1 ;
int b, sumb = 0;
for (int i = 0, more = -1 ; i < l ; i++) {
/* Get next byte b from URL segment s */
switch (ch = s.charAt(i)) {
case '%':
ch = s.charAt (++i) ;
int hb = (Character.isDigit ((char) ch)
? ch - '0'
: 10+Character.toLowerCase((char) ch) - 'a') & 0xF ;
ch = s.charAt (++i) ;
int lb = (Character.isDigit ((char) ch)
? ch - '0'
: 10+Character.toLowerCase ((char) ch)-'a') & 0xF ;
b = (hb << 4) | lb ;
break ;
case '+':
b = ' ' ;
break ;
default:
b = ch ;
}
/* Decode byte b as UTF-8, sumb collects incomplete chars */
if ((b & 0xc0) == 0x80) { // 10xxxxxx (continuation byte)
sumb = (sumb << 6) | (b & 0x3f) ; // Add 6 bits to sumb
if (--more == 0) sbuf.append((char) sumb) ; // Add char to sbuf
} else if ((b & 0x80) == 0x00) { // 0xxxxxxx (yields 7 bits)
sbuf.append((char) b) ; // Store in sbuf
} else if ((b & 0xe0) == 0xc0) { // 110xxxxx (yields 5 bits)
sumb = b & 0x1f;
more = 1; // Expect 1 more byte
} else if ((b & 0xf0) == 0xe0) { // 1110xxxx (yields 4 bits)
sumb = b & 0x0f;
more = 2; // Expect 2 more bytes
} else if ((b & 0xf8) == 0xf0) { // 11110xxx (yields 3 bits)
sumb = b & 0x07;
more = 3; // Expect 3 more bytes
} else if ((b & 0xfc) == 0xf8) { // 111110xx (yields 2 bits)
sumb = b & 0x03;
more = 4; // Expect 4 more bytes
} else /*if ((b & 0xfe) == 0xfc)*/ { // 1111110x (yields 1 bit)
sumb = b & 0x01;
more = 5; // Expect 5 more bytes
}
/* We don't test if the UTF-8 encoding is well-formed */
}
return sbuf.toString() ;
}
Labels: Blackberry, J2ME
Saturday, July 11, 2009
In order to show GIF images in Blackberry applications you have to disable exporting all images to png format. This can be done from JDE by right clicking the project and going to properties. In resources tab select “Don’t convert image files to png”.
Now add the gif image in the project. And add this class with your project.
/* * AnimatedGIFField.java
*
* © <your company here>, 2003-2008
* Confidential and proprietary.
*/
import net.rim.device.api.ui.UiApplication; import net.rim.device.api.system.GIFEncodedImage;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.BitmapField;
//A field that displays an animated GIF.
public class AnimatedGIFField extends BitmapField
{
private GIFEncodedImage _image; //The image to draw.
private int _currentFrame; //The current frame in the animation sequence.
private int _width; //The width of the image (background frame).
private int _height; //The height of the image (background frame).
private AnimatorThread _animatorThread;
public AnimatedGIFField(GIFEncodedImage image)
{
this(image, 0);
}
public AnimatedGIFField(GIFEncodedImage image, long style)
{
//Call super to setup the field with the specified style.
//The image is passed in as well for the field to
//configure its required size.
super(image.getBitmap(), style);
//Store the image and it's dimensions.
_image = image;
_width = image.getWidth();
_height = image.getHeight();
//Start the animation thread.
_animatorThread = new AnimatorThread(this);
_animatorThread.start();
}
protected void paint(Graphics graphics)
{
//Call super.paint. This will draw the first background
//frame and handle any required focus drawing.
super.paint(graphics);
//Don't redraw the background if this is the first frame.
if (_currentFrame != 0)
{
//Draw the animation frame.
graphics.drawImage(_image.getFrameLeft(_currentFrame), _image.getFrameTop(_currentFrame),
_image.getFrameWidth(_currentFrame), _image.getFrameHeight(_currentFrame), _image, _currentFrame, 0, 0);
}
}
//Stop the animation thread when the screen the field is on is
//popped off of the display stack.
protected void onUndisplay()
{
_animatorThread.stop();
super.onUndisplay();
}
//A thread to handle the animation.
private class AnimatorThread extends Thread
{
private AnimatedGIFField _theField;
private boolean _keepGoing = true;
private int _totalFrames; //The total number of frames in the image.
private int _loopCount; //The number of times the animation has looped (completed).
private int _totalLoops; //The number of times the animation should loop (set in the image).
public AnimatorThread(AnimatedGIFField theField)
{
_theField = theField;
_totalFrames = _image.getFrameCount();
_totalLoops = _image.getIterations();
}
public synchronized void stop()
{
_keepGoing = false;
}
public void run()
{
while(_keepGoing)
{
//Invalidate the field so that it is redrawn.
UiApplication.getUiApplication().invokeAndWait(new Runnable()
{
public void run()
{
_theField.invalidate();
}
});
try
{
//Sleep for the current frame delay before
//the next frame is drawn.
sleep(_image.getFrameDelay(_currentFrame) * 10);
}
catch (InterruptedException iex)
{} //Couldn't sleep.
//Increment the frame.
++_currentFrame;
if (_currentFrame == _totalFrames)
{
//Reset back to frame 0 if we have reached the end.
_currentFrame = 0;
++_loopCount;
//Check if the animation should continue.
if (_loopCount == _totalLoops)
{
_keepGoing = false;
}
}
}
}
}
}
This class will create a custom field type object. You can add it with a Screen type objects.
The following code will add a GIF image with a Screen type object
AnimatedGIFField testanimated= new AnimatedGIFField((GIFEncodedImage)(GIFEncodedImage.getEncodedImageResource( "loading2.gif" )),AnimatedGIFField.FIELD_LEFT);
//add(answer);
add(testanimated);
You are done. Let me know if you found any difficulties adding it.
Labels: Blackberry, GIF, Java