Wednesday, April 27, 2011

Screen Resolutions of Blackberry Devices



BlackBerry 7100                   240 x 260
BlackBerry 7100i                  240 x 260
BlackBerry 7100g                 240 x 260
BlackBerry 7100r                  240 x 260
BlackBerry 7100v                 240 x 260
BlackBerry 7100x                 240 x 260
BlackBerry 7100t                  324 x 352
BlackBerry 7105t                  240 x 260
BlackBerry 7130                   240 x 260
BlackBerry 7130c                 240 x 260
BlackBerry 7130e                 240 x 260
BlackBerry 7130g                 240 x 260
BlackBerry 7130v                 240 x 260
BlackBerry 7210                   240 x 160
BlackBerry 7220                   240 x 160
BlackBerry 7230                   240 x 160
BlackBerry 7250                   240 x 160
BlackBerry 7270                   240 x 160
BlackBerry 7280                   240 x 160
BlackBerry 7290                   240 x 160
BlackBerry 7510                   240 x 160
BlackBerry 7520                   240 x 160
BlackBerry 7730                   240 x 240
BlackBerry 7750                   240 x 240
BlackBerry 7780                   240 x 240
BlackBerry 8100                   240 x 260
BlackBerry 8120                   240 x 260
BlackBerry 8130                   240 x 260
BlackBerry 8220                   240 x 320
BlackBerry 8300                   320 x 240
BlackBerry 8310                   320 x 240
Blackberry 8320                   320 x 240
BlackBerry 8330                   320 x 240
BlackBerry 8350i                  320 x 240
BlackBerry 8520                   320 x 240
BlackBerry 8530                   320 x 240
BlackBerry 857                     160 x 160
BlackBerry 8700 (c/r/f/g)       320 x 240
BlackBerry 8703e                  320 x 240
BlackBerry 8707 (g/h/v)         320 x 240
BlackBerry 8800                    320 x 240
BlackBerry 8820                    320 x 240
BlackBerry 8830                    320 x 240
BlackBerry 8900                    480 x 360
BlackBerry 9000                    480 x 320
BlackBerry 9105                    360 x 400
BlackBerry 9501                    32 x 65
BlackBerry 9500                    360 x 480
BlackBerry 9520                    360 x 480
BlackBerry 9530                    360 x 480
BlackBerry 9550                    360 x 480
BlackBerry 957                     160 x 160
BlackBerry 9630                   480 x 360
BlackBerry 9700                   480 x 360
BlackBerry 9800                   360X480

Sunday, April 24, 2011

Configure Eclipse for Blackberry

System Requirements:


1) Monitor Resolution - 1024X768 or higher.

2) Intel Pentium 4 Processor

3) Windows Vista/XP/7.

4) JDK Versio 5 or 6;

5) BB Eclipse Pluggin

6) BB e_JDE's


Things To Download with links:


1) Download JDK

http://java.sun.com/javase/downloads//index.jsp


2) Download Eclipse IDE (Ganymede/Helios etc.. higher versions)

http://www.eclipse.org/downloads/


3) To get BB tools go to:

http://na.blackberry.com/eng/developers/resources/devtools.jsp



Installation:


1) Install JDK

2) Install Eclipse (Just unzip the folder).

3) Now install pluggins.


Setting Environment Variables:


Path variables tell the JVM where to look for user defined classes and packages when running java programs.


1) Right Clivk on MyComputer

2) Go to properties

3) Advanced System Properties.

4) Environment Variables.


1) Create Variable : JAVA_HOME

PATH : D:\SUN\SDK\JDK


2) Now just append %JAVA_HOME%\jre\bin; to the end of your CLASSPATH and PATH variable


3) To verify that you have set environment variable properly :

type java-version in windows command prompt.

If correctly installed it will show you all versions installed else error message.

Thursday, April 7, 2011

Send SMS in Blackberry using J2ME

Hello,

When i had to implement this feature then i surfed a lot.I was new to Blackberry and J2ME.
I saw several posts but non was able to help me truely.

I gathered up the code and made it to work.
I had to send the message to the person whose call i missed up or to person whose incomming call is explicitly disconnected by me when i was busy.

The moment i disconnect the call, immediately a message is send to thta number.
That too should be done in a separate thread to avoid hang ups.

Hope it help someone. :)


Send SMS from Blackberry Application:

import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.Datagram;
import javax.microedition.io.DatagramConnection;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;

import net.rim.device.api.system.RadioInfo;
public class SendSMS extends Thread {
    private String to;
    private String msg;

    public SendSMS(String to, String msg) {
        this.to = to;
        this.msg = msg;

    }
    public void run() {
        if (RadioInfo.getNetworkType() == RadioInfo.NETWORK_CDMA) {
            DatagramConnection dc = null;
            try {
                dc = (DatagramConnection) Connector.open("sms://" + to);
                byte[] data = msg.getBytes();
                Datagram dg = dc.newDatagram(dc.getMaximumLength());
                dg.setData(data, 0, data.length);
                dc.send(dg);
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    dc.close();
                } catch (IOException e) {
                    System.out.println(e.getMessage());
                }
            }

        } else {
            MessageConnection mc = null;
            try {
                mc = (MessageConnection) Connector
                        .open("sms://" + to);
                TextMessage m = (TextMessage) mc
                        .newMessage(MessageConnection.TEXT_MESSAGE);
                m.setPayloadText(msg);
                mc.send(m);
            } catch (IOException e1) {
                e1.printStackTrace();
            } finally {
                try {
                    mc.close();
                } catch (IOException e) {
                    System.out.println(e.getMessage());

                }
            }
        }
    }

}

Send msg when call gets disconnected:
public void callDisconnected(int callId)
{
        final PhoneCall call = Phone.getCall(callId);
        final String number = call.getDisplayPhoneNumber();
        SendSMS sendSMS = new SendSMS(number, "message");
        sendSMS.start();
        super.callDisconnected(callId);
    }
You can try other methods also depending upon the requirements.


Links:
http://stackoverflow.com/questions/3051301/send-sms-from-background-thread-in-blackberry-using-j2me

Tuesday, April 5, 2011

Sending Email with Attachment in Blackberry using J2ME


Now days in almost every application user has to send email and share the contents such as score of any game etc..
Using the below code in any blackberry application one can easily do that.


Address[] address = new Address[1];
try

  {
    address[0] = new Address(email,name);
  }

   catch (AddressException e1)
    {
      e1.printStackTrace();
    }
 byte[] data = readFile();
 Multipart multipart = new Multipart();
 SupportedAttachmentPart attach ;

 attach = new SupportedAttachmentPart(multipart,"application/x-example", "test.txt", data);
 multipart.addBodyPart(attach);
 Message msg = new Message();

// add the recipient list to the message
 try

  {
     msg.addRecipients(Message.RecipientType.TO, address);

    // set a subject for the message
   msg.setSubject("Mail from mobile");
   msg.setContent(multipart);
  }

  catch (MessagingException e1)
   {
      e1.printStackTrace();
   }


try

 {
     Transport.send(msg);
 }

 catch (MessagingException e) {
    System.out.println(e.getMessage());
  }
 private static byte[] readFile() {
 String fName ="
file:///store/home/user/test.txt";
 byte[] data = null;
 FileConnection fconn = null;
 DataInputStream is = null;
 try

  {
      fconn = (FileConnection) Connector.open(fName, Connector.READ_WRITE);
      is = fconn.openDataInputStream();
     data = IOUtilities.streamToBytes(is);
   }

  catch (IOException e)
   {
      System.out.println(e.getMessage());
   }

  finally
  {
     try

     {
        if (null != is)
        is.close();
        if (null != fconn)
       fconn.close();
     }

   catch (IOException e)
     {
             System.out.println(e.getMessage());
      }
  }
 return data;
 }


Have a look at this sample image:

Custom Popups in Blackberry



Procedure:

1) Create a class that extends Popup .
2) In this class use your own manager
a) take one vertical field manager
b) add some text using label field and also a button inside this vertica field manager
c) And add vertical field manager in your screen


PopupScreen popup = new PopupScreen(new VerticalFieldManager());
popup.add(new LabelField("Hello!"));
popup.add(new ButtonField("OK"));



Create Border less Popup screen
PopupScreen popup = new PopupScreen(new VerticalFieldManager());
popup.add(new LabelField("Hello!"));
Border border = BorderFactory.createSimpleBorder(new XYEdges(), Border.STYLE_TRANSPARENT);
popup.setBorder(border);



Push popup screen:

UiApplication.getUiApplication().pushScreen(new MyPopup());

Closing a popup scren when uer clicks on Escape Key:
Need to implement Keychar method

popupscreen1=new PopupScreen(myverticalfieldmanager)
   {
        protected boolean keyChar(char c, int status, int time)
          {
               if (c == Characters.ESCAPE)
              close();
              return super.keyChar(c, status, time);
         }
   };



Have a look at this: