Wednesday, September 30, 2009

You 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

Saturday, August 8, 2009

System.getProperty("browser.useragent")

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() ;
}

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”.

dontpng

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.

9530

Friday, May 22, 2009

In my server webmin was installed but mysql was not there. The server was running centos5.3.

After some googling i found some solutions and here is the combination which might solve your problems.

You have to have access to a shell window in the server. You can access using putty or
by loggin into your webmin, go to Others->Command Shell.You can type commands in this shell.

If using putty, you will get the command shell any way :) after logging in.

Inorder to check if mysql is already installed or not run this command
which mysql
If found it will show some directory name otherwise not found

In order to remove old mysql
yum remove mysql-server
yum remove mysql

Now to install mysql run this command from the shell or a command line access point
yum install mysql-server
yum install mysql
yum install mysql-devel

Inorder to use with php
yum install php-mysql

By default mysql has the no passward. To change the password in command shell write the following commands
mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;

That's all, if anything is missing let me know

Wednesday, April 15, 2009

Shuvo noboborsho


bangla 1416


Monday, March 23, 2009

Movie

Watch sad movies alone, funny movies all together

Sunday, February 22, 2009

I was in a need to show a date picker with a java application. After some searching I came into here for a free calendar component.

Might become useful for somebody.

And to show a time picker control, you can use the jspinner itself, nothing extra is required. It amazed me

JSpinner spinner =
new JSpinner(sm);
JSpinner.DateEditor de = new JSpinner.DateEditor(spinner, "hh:mm");
spinner.setEditor(de);


You can do it in netbeans by going into the properties of jspinner and changing the Editor properties from there,

When you have a bluetooth dongle you can receive business card/files/contacts from mobile devices using your bluetooth software. Now if you want to receive contacts/file in your own software and you also don't want to install any application in your mobile device then you can continue reading.

The main thing is to open a obex receiver in your bluetooth device from your application, then other remote device can do ServiceSearch and find your dongle to send contact/vcard/business card without installing any application.

The trick is done using OBEX, to know about OBEX google please.
I am going to use Java as my source language as there is already a API made named bluecove

I tried to find an already made project and couldn't find after some searching(may be my search strings were weak)

After one/two day i came to the bluecove code repository, there i found the source of it.

So i made a netbeans project of my own and is posted at the end of this post(i think if you are interested then you are now looking into the end section for the code ;) )

Ok no rush, the original source code of bluecove people are here. Thanks god i found it.

And my code in netbeans can be found here.

To run it in windows no problem, but to run in it newer ubuntu when this post was written you had to include bluecove-gpl with the project, which is already included and you will need to install libbluetooth-dev for ubuntu 8.10 with this command
sudo apt-get install libbluetooth-dev

I hope the code works.

So basically the thing is, i want to send files to mobile devices without installing any software in mobile handset. So how can i do that? Obviously google.

You can send files to mobile device using OBEX, a file transfer protocol for bluetooth devices, it's in jsr82.

And there is a api known as bluecove which has things ready made :). Supported stack(don't ask me what it is, i know little about i) list can be found here. A list of jsr82 compatible handsets can be found here.

I work with netbeans, you can get the latest netbeans ide from here.

You will need the bluecove-api jar, and you can download from here. The jar i used was named "bluecove-2.1.0.jar", Now here is an issue, if you want your application to run in ubuntu/linux then you will also need a jar called "bluecove-gpl-2.1.0.jar" which can be found in here. So copy this jars to the netbeans project folder. And add these jar's in the project libraries, go to project properties and from libraries at left select add jar/folder and show the jars.


Now you are ready to use bluecove with your project. Do some coding things as you like.

Here I am going to make an application which will discover devices around it and send them a file.

I used real bluetooth devices and handset. There is also possible to use emulators to emulate bluetooth dongle and also mobile device. But I don't know how, you can let me know if you find a easy one.

Ok now coding time, the application has three main parts
1. UI which is shown to user
2. BluetoothBrowser: a class that discovers remote devices and put them in a list, and this class is also used to find the OBEX url for sending files to remote device.
3. A sender class which sends file to remotedevices using the OBEXUrl found previously.

Now, while starting to work first, i found some examples where connectionurl was hardcoded like
btgeop://address:9
But this was not working for me, this is a port number in remote device in which obex service is running, but this port number is not valid for all handsets. For nokia it works fine, but in Sony Ericsson the obex port number is 6, so to make the program independent a findObex function was used to query the remote device to know it's obex connection url and then it was used to send the file. So more generic way. This part almost made me to fail as I was not able to do while the port number was 9 with sony ericsson.

The other codes are there, you might find similarity with codes in the net. But what can i do , i am a google coder. So things are copy paste copy paste bla bla.

The application starts discovery first then tries to send a jpeg file from "C://a.jpg" file.

Enought talking, now the happy part, the Source Code :).
The full source can be found here. The code is not tested, i plugged my code from other projects and made a quick project. So if you find now working let me know.

By the way for linux things, you might have a look at here
For ubuntu 8.10 additional library is required, to install that library in terminal run this command
sudo apt-get install libbluetooth-dev

It will save your time, in ubuntu i was getting bluecove stack not found though my bluetooth device was there, just running the above command will solve the issue, And remember to include the bluecove-gpl-2.10.0 jar with your project. the gpl jar has to be with the same version of your main bluecove jar.

I think i am still not clear to you. what can i do i am bad at writing and explaining.

The next one i am wishing to write is "How you can receive contacts/vcard/business card" from mobile devices using obex.

First you have to install jdk by running this command in terminal
sudo apt-get install sun-java5-jdk sun-java5-plugin

for jdk 6
sudo apt-get install sun-java6-jdk sun-java6-plugin

Then download netbeans ide from here

The downloaded file will be a sh file, most probably in your desktop

Now open the terminal(from Application->Accessories)

Then go to your desktop folder or the folder in which you have downloaded the installer file

cd Desktop

Then run this command, the last portion of the command will be the name of the file you downloaded

sudo sh netbeans-6.5-ml-javase-linux.sh


That's it, your installer will start and the next processes are as usual.

More detailed instructions can be found in Netbeans Wiki page

Wednesday, January 7, 2009

I am liking this song right now.



Lyrics goes like this:
This is Your Life

Yesterday is a wrinkle on your forehead
Yesterday is a promise that you’ve broken
Don’t close your eyes, don’t close your eyes
This is your life and today is all you’ve got now
Yeah, and today is all you’ll ever have
Don’t close your eyes
Don’t close your eyes

This is your life, are you who you want to be
This is your life, are you who you want to be
This is your life, is it everything you dreamed that it would be
When the world was younger and you had everything to lose

Yesterday is a kid in the corner
Yesterday is dead and over

This is your life, are you who you want to be
This is your life, are you who you want to be
This is your life, is it everything you dreamed that it would be
When the world was younger and you had everything to lose

Don’t close your eyes
Don’t close your eyes
Don’t close your eyes
Don’t close your eyes

This is your life are you who you want to be
This is your life are you who you want to be

This is your life, are you who you want to be
This is your life, are you who you want to be
This is your life, is it everything you dreamed it would be
When the world was younger and you had everything to lose

And you had everything to lose

Friday, January 2, 2009

From last month i was working(or trying to work) with flash as3. Finished a Ludo game started by saikat first. I already told about multiplayer pool in this blog, some new games also saw light of world too. It's fun and a bit odd to work with flash. You need some good ideas to make a good game. May be the simplest idea can produce the next killer game.

Enough of now, here goes some game links in which i took part(in some i worked, in some i just played as much as i could :D )

MultiPlayer Pool - The pool game multiplayered
Connectica - Connect pipes from star to end to let the water flow
SameBall - It's a fun game, you have to match 3/more balls in a row/column.
Single Player Ludo - We know this game, our childhood play :). Not so good though. May be multiplayer version some time.

And hoping to make the list bigger and bigger.

Till then

HAPPY NEW YEAR
what'll be now?