Wednesday, April 11, 2012

Blackberry recipes

Today my planning to Blackberry simple task but most of time it's use on our application.

1. Get IMEI No:
private String getIMEINumber() {
  byte[] imeiByteArray = net.rim.device.api.system.GPRSInfo.getIMEI();
  String imei = net.rim.device.api.system.GPRSInfo.imeiToString(imeiByteArray);
  imeiByteArray = null;
  return imei;

2. Set Font on LabelField:
 LabelField lblTemp = new LabelField("Temp");
 FontFamily fontFamily[] = FontFamily.getFontFamilies();
 Font font = fontFamily[1].getFont(FontFamily.CBTF_FONT, 12);

3. get List of Install Application:
get an array of handles into all modules now.
net.rim.device.api.system.CodeModuleManager.getApplicationDescriptors(int moduleHandle)
To get ApplicationDescriptors associated with the module. You will have to sort out which modules are libraries and which are applications.

4.Sent Mail:
private void invokeMail(String emailID){
   Message m = new Message();
   Address a = new Address(""+emailID, "Mail Title");
   Address[] addresses = {a};
   m.addRecipients(net.rim.blackberry.api.mail.Message.RecipientType.TO, addresses);
   m.setSubject("Mail Subject");
   Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(m));
  }catch(Exception e){
    System.out.println("Error on Open Mail");
5. Invoke Call
private void invokeCall(String callNo){
        PhoneArguments call = new PhoneArguments(PhoneArguments.ARG_CALL, callNo);
 Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, call);
Read Image from SD Card
public Bitmap getImage(){
    Bitmap bitmapImage=null;
        InputStream input;
        FileConnection fconn = (FileConnection)"file:///store/home/user/dirname/imgname.png", Connector.READ_WRITE);
        input = fconn.openInputStream();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int j = 0;
        while(( != -1) {
        byte[] byteArray = baos.toByteArray();

        bitmapImage = Bitmap.createBitmapFromBytes(byteArray,0,byteArray.length,1);

    }catch(Exception ioe){
    return bitmapImage;


No comments:

Post a Comment