Monday, 17 June 2013

Blackberry: Custom Popup Screen[Forgot Password Example]

Here I am providing one example that shows how we customize our Popup Screen. We can use this like a popup Screen or Dialog Screen. 
Below link is the Example for the Custom Popup Screen and I am showing an example of Forgot Password. 

In this you will get again two custom classes. Like, PictureBackgroundButtonField and CustomTextField where we can use images directly to the buttons and text fields. 
It will look like the below image:

Lets try this one. 
Feel free to ask questions.





Tuesday, 11 June 2013

Blackberry: Post Data Using JSON Object

We can post the data by the JSON format. 
For this first,
1. We have to take all the keys and values in One Hash table or Array of Hash tables(Vector)
2. Convert it into JSON object.
3. Send to server.
packagecom.alishaik.thread;
importjava.io.InputStream;
importjava.io.OutputStream;
importjava.util.Hashtable;
importjavax.microedition.io.Connector;
importjavax.microedition.io.HttpConnection;
importnet.rim.blackberry.api.browser.URLEncodedPostData;
importnet.rim.device.api.io.http.HttpProtocolConstants;
importnet.rim.device.api.ui.Screen;
importnet.rim.device.api.ui.UiApplication;
importcom.hiddenbrains.ddft.common.CommonMethods;
importcom.hiddenbrains.ddft.common.MessageScreen;
importcom.hiddenbrains.ddft.common.Utility;
importcom.hiddenbrains.ddft.json.JSONObject;
public class PostDataThread extendsThread
{
    privateHttpConnection httpConnection;
    privateInputStream inputStream;
    privateStringBuffer stringBuffer=newStringBuffer();
    privateHashtable hashTable;
    privateString URL="";
    privateintindex=0;
     
      
    public PostDataThread(String url, Hashtable hash,intindex) 
    {
//      System.out.println("=========WEB SERVICE===========: "+url);        
        URL=Utility.escapeHTML(url)+CommonMethods.updateConnectionSuffix();//interface=wifi; or deviceside=false;
        this.index=index;
        this.hashTable=hash;//Here I am taking one Hashtable. You can manage according to your requirement.
    }
     
    publicvoidrun() 
    {
        try
        {
            httpConnection=(HttpConnection)Connector.open(URL);
            httpConnection.setRequestMethod(HttpConnection.POST);
             
            URLEncodedPostData oPostData =newURLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, false);
            oPostData.setData(provideJSONObject());//IMPORTANT
             
            byte[] postBytes = oPostData.getBytes();
            httpConnection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_TYPE,"application / requestJson");
            httpConnection.setRequestProperty(HttpProtocolConstants.HEADER_CONTENT_LENGTH, Integer.toString(postBytes.length));
            
            OutputStream strmOut = httpConnection.openOutputStream();
            strmOut.write(postBytes);
            strmOut.flush();
            strmOut.close();
             
            intresponse=httpConnection.getResponseCode();
            if(response==HttpConnection.HTTP_OK)
            {
                inputStream = httpConnection.openInputStream();
                intc;
                while((c=inputStream.read())!=-1)
                {
                    stringBuffer.append((char)c);
                }                   
                parseData(stringBuffer.toString());             
            }
            else
                parserInterface.didFailParser("Connection failure HTTP Response: "+response);
        }
        catch(finalException e) 
        {
            String msg=e.getMessage();
            if(msg==null)
                msg="No Data Found";
            //Show failure alert here
        }
        finally
        {
            try
            {
                if(httpConnection!=null)
                    httpConnection.close();
                if(inputStream!=null)
                    inputStream.close();
            } 
            catch(Exception e2) 
            {}          
        }
    }
     
    private String provideJSONObject()
    {
        try
        {
            JSONObject jsonObj=newJSONObject();
            jsonObj.put("data", hashTable);//Getting correct data; You can check here
//          System.out.println("======================JSON STRING FOR POSTING: "+jsonObj.toString());
            returnjsonObj.toString();
        } 
        catch(Exception e) 
        {
            returnnull;
        }
    }
     
    private void parseData(String responseString) 
    {
        responseString="["+responseString+"]";
        System.out.println("======================\n\n"+responseString+"\n\n===================");
        //Do what you want.        
    }
}
and the method for Utility.escapeHTML(url) is:

public static String escapeHTML(String s)
{
               StringBuffer sb = new StringBuffer();
               int n = s.length();
               for (int i = 0; i < n; i++) {
                     char c = s.charAt(i);
                      switch (c) {
                                           case ‘ ‘: sb.append(“%20″); break;
                                         default: sb.append(c); break;
                     }
             }
            return sb.toString();
}
You can get this class by this below link:

Sunday, 9 June 2013

Blackberry: Video Recording in Blackberry

For video recording first we have to check the memory available in Blackberry. According to that we have to go to the next step.
Download the zip file for the example for Video recording in Blackberry

Monday, 3 June 2013

Create Route on Map in IOS 6


We can easily create Routes between two places.
Here we have 6 main methods:
-(void)addAnnotationsToMapView
-(NSArray*)getRoutePointFrom:(CLLocationCoordinate2D)origin to:(CLLocationCoordinate2D)destination
-(NSMutableArray *)decodePolyLine:(NSMutableString *)encodedString
-(void)drawRoute
-(void)centerMap
- (MKOverlayView*)mapView:(MKMapView*)theMapView viewForOverlay:(id <MKOverlay>)overlay

Take the code from below link:

Saturday, 18 May 2013

Blackberry: QR-Code Reader for BB-5.0


Yes, we can read the QRCode in Blackberry 5.0 api applications. For this we have to follow some points from this link:
You can download the code from this below link:

Blackberry : Any Type of Barcode Generator


We can scan Any type of barcode using blackberry. You can download the code from here.
First see the BarcodeScanner in blackberry 6.0 sample codes.
Take the code from this link : 

Saturday, 6 April 2013

INSTAGRAM IN IOS

Find the below GITHUB link to download the INSTAGRAM sample DEMO.

https://github.com/alishaik001/Instagram-IOS

Thanks.

Create CUSTOM MENU in Blackberry Example

Here CustomMenu is a class which we create any number of menu and according to the tag value

=================StartUp.java================

package com.alishaik.custommenu;

public class StartUp extends UiApplication
{
    public static void main(String[] ali)
    {
        StartUp theApp = new StartUp();      
        theApp.enterEventDispatcher();
    }
   
    public StartUp()
    {       
        pushScreen(new FirstScreen());
    }   
   
    public static void showAlertMessage(final String message)
    {
        UiApplication.getUiApplication().invokeLater(new Runnable()
        {
            public void run()
            {
                Dialog.alert(message);
            }
        });
    }
}
=================FirstScreen.java================

package com.alishaik.custommenu;

public class FirstScreen extends MainScreen implements MenuInterface
{
    private ButtonField clickButton;
    private CustomMenu firstMenu1,firstMenu2;
   
    public FirstScreen()
    {
        createGUI();
    }

    private void createGUI()
    {
        firstMenu1=new CustomMenu("First1", 100, 101, 1);
        firstMenu1.setMenuListener(this);
        addMenuItem(firstMenu1);
       
        firstMenu2=new CustomMenu("First2", 100, 101, 2);
        firstMenu2.setMenuListener(this);
        addMenuItem(firstMenu2);
       
       
        add(new LabelField("First Screen", Field.FOCUSABLE));
        //ButtonField.CONSUME_CLICK if you are not writing this every screen menu shows.
        clickButton=new ButtonField("Clik to go Next", Field.FOCUSABLE|ButtonField.CONSUME_CLICK);
        clickButton.setChangeListener(new FieldChangeListener()
        {
            public void fieldChanged(Field field, int context)
            {
                UiApplication.getUiApplication().pushScreen(new SecondScreen());
            }
        });
        add(clickButton);
    }
   
    public void onMenuPressed(String menuText, int tag)
    {
        StartUp.showAlertMessage("You Selected "+menuText);
        if(tag==1)
        {
            //FirstMenu1 Selected;
        }
        else
        {
            //FirstMenu2 Selected;
        }
    }   
   
    protected boolean onSavePrompt()
    {
        return true;
    }
}

=================SecondScreen.java================

package com.alishaik.custommenu;

public final class SecondScreen extends MainScreen implements MenuInterface
{
    private ButtonField clickButton;
    private CustomMenu secondMenu1,secondMenu2;
   
    public SecondScreen()
    {
        createGUI();
    }

    private void createGUI()
    {
        secondMenu1=new CustomMenu("Second1", 100, 101, 1);
        secondMenu1.setMenuListener(this);
        addMenuItem(secondMenu1);
       
        secondMenu2=new CustomMenu("Second2", 100, 101, 2);
        secondMenu2.setMenuListener(this);
        addMenuItem(secondMenu2);
       
        add(new LabelField("Second Screen", Field.FOCUSABLE));
        //ButtonField.CONSUME_CLICK if you are not writing this every screen menu shows.
        clickButton=new ButtonField("Back button", Field.FOCUSABLE|ButtonField.CONSUME_CLICK);       
        clickButton.setChangeListener(new FieldChangeListener()
        {
            public void fieldChanged(Field field, int context)
            {
                UiApplication.getUiApplication().popScreen(SecondScreen.this);
                return;   
            }
        });
        add(clickButton);
    }

    public void onMenuPressed(String menuText, int tag)
    {
        StartUp.showAlertMessage("You Selected "+menuText);
        if(tag==1)
        {
            //SecondMenu1 Selected;
        }
        else
        {
            //SecondMenu2 Selected;
        }
    }
   
    protected boolean onSavePrompt()
    {
        return true;
    }
}


=================MenuInterface.java================

package com.alishaik.custommenu;

public interface MenuInterface
{
    public void onMenuPressed(String menuText,int tag);
}


=================CustomMenu.java================

package com.alishaik.custommenu;

public class CustomMenu extends MenuItem
{
    private MenuInterface menuInterface;
    private String menuText;
    private int tag;
   
    public CustomMenu(String text, int ordinal, int priority, int tag)
    {
        super(text, ordinal, priority);
        this.menuText=text;
        this.tag=tag;
    }

    public void run()
    {
        menuInterface.onMenuPressed(menuText, tag);
    }
   
    public void setMenuListener(MenuInterface listener)
    {
        this.menuInterface=listener;
    }       
}
 

any doubts feel free to mail on alishaik001@gmail.com 


Monday, 27 August 2012

Blackberry - Rotate an image in any degree

This BitmapRotation works from Blackberry Version 5.0 on-wards.

Do the following steps:

1. Download the zip file from this link: BitmapRotate at down side.

2. Extract and take the ImageManipulator.java from that add to your project;

3. and use this code from this link: RotatingBitmap on Blackberry;

or

take MY code from the below LINK for rotate an image in BB:

BitmapRotate.zip

Otherwise take this code:

1. Download the zip file from this link: BitmapRotate at down side.

2. Extract and take the ImageManipulator.java from that add to your project;

and then in our code:

================== StartUp.java===================



public class StartUp extends UiApplication
{
public static void main(String[] args)
{
StartUp app = new StartUp();
app.enterEventDispatcher();
}

public StartUp()
{
RotateScreen screen = new RotateScreen();
pushScreen(screen);
}

public static void showAlertMessage(final String message)
{
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
Dialog.alert(message);
}
});
}
}


================ RotateScreen.java=============


public class RotateScreen extends MainScreen
{
private BitmapField bitmapField = new BitmapField();
private Bitmap bitmap = Bitmap.getBitmapResource("simple.png");
private ImageManipulator imageManip = new ImageManipulator(bitmap);
private int angle=0;

private VerticalFieldManager vfm = new VerticalFieldManager(VerticalFieldManager.USE_ALL_HEIGHT | VerticalFieldManager.USE_ALL_WIDTH)
{
protected void paintBackground(Graphics g)
{
g.setBackgroundColor(Color.GREEN);
g.clear();
}
};
public RotateScreen()
{
super(MainScreen.HORIZONTAL_SCROLLBAR | MainScreen.VERTICAL_SCROLLBAR);
bitmapField.setBitmap(bitmap);
vfm.add(bitmapField);
add(vfm);
addMenuItem(new Restore());
addMenuItem(new Rotate());
addMenuItem(new Continuous());
}

private class Restore extends MenuItem
{
public Restore()
{
super("Restore", 0, 100);
}
public void run()
{
try {
angle = 0;
imageManip.resetTransform();
bitmapField.setBitmap(imageManip.transformAndPaintBitmap());
invalidate();
} catch (Exception e) {
StartUp.showAlertMessage(e.toString());
}

}
}

private class Rotate extends MenuItem {
public Rotate() {
super("Rotate", 0, 100);
}

public void run()
{
try
{
angle +=90;
imageManip.transformByAngle(angle, false, false);
bitmapField.setBitmap(imageManip.transformAndPaintBitmap());
invalidate();
}
catch (Exception e)
{
StartUp.showAlertMessage(e.toString());
}
}
}

private class Continuous extends MenuItem {
public Continuous()
{
super("Continuous", 0, 100);
}

public void run()
{
try
{
new Thread()
{
public void run()
{
for (int angle = 1; angle <= 360; angle++)
{
imageManip.transformByAngle(angle, false, false);
synchronized (UiApplication.getEventLock())
{
bitmapField.setBitmap(imageManip.transformAndPaintBitmap());
invalidate();
}
try
{
Thread.sleep(500);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}.start();

} catch (Exception e) {
StartUp.showAlertMessage(e.toString());
}

}
}
}

See the below Screen shots:







Wednesday, 11 April 2012

QRCode Scanning for Blackberry Version 5.0

For this Take the sample code from this following link:

QRCode 5.0

In the above sample application we have QRCode implementation is in "com.alishaik.qrcode.startup";

and if you want to do the this in separately you must add the packages which are provided in the below link:

ZXIng For 5.0  and you and do by your self;

The above ZXIng For 5.0  link nothing but I downloaded this in the below link and separate the packages

http://code.google.com/p/zxing/downloads/list

For Version>5.0 no need to take all these; From 6.0 on wards we have the packages;

I think it helps you alot;

For 6.0 see this below links:

Generate QRCode Image In Blackberry

and

Scan AnyType of Barcode Images

any doubts feel free to mail on alishaik001@gmail.com

Regards,
ALI SHAIK

Wednesday, 28 March 2012

Generate QRCode Image In Blackberry

This following Code gives the Bitmap Image of QRCode when User Enters Text/PhoneNumber/Url:
---------------------------------------QRCodeScreen.java-----------------------------------

public class QRCodeScreen extends MainScreen implements FieldChangeListener
{
    private static final int BARCODE_WIDTH=250;
    private Font font=Font.getDefault().derive(Font.BOLD|Font.ITALIC, 20);
    private BitmapField barcodeImage;
    public BasicEditField enterText;
    public ButtonField create;
    public QRCodeScreen()
    {
        createGUI();
    }

    private void createGUI()
    {
        barcodeImage=new BitmapField(new Bitmap(BARCODE_WIDTH, BARCODE_WIDTH),FIELD_HCENTER);
        barcodeImage.setBorder(BorderFactory.createBevelBorder(new XYEdges(2, 2, 2, 2)));
        add(barcodeImage);
       
        LabelField label=new LabelField("Enter Any Text/URL/Phone Number/SMS",Field.NON_FOCUSABLE);
        label.setFont(font);
        label.setPadding(5, 0, 5, 0);
        add(label);
       
        enterText=new BasicEditField("", "",250,BasicEditField.FOCUSABLE);       
        enterText.setFont(font);
        add(enterText);
       
        create=new ButtonField("Create BarCode",FIELD_HCENTER);
        create.setPadding(5, 0, 0, 0);
        create.setFont(font);
        create.setChangeListener(this);
        add(create);
    }
   
    public void fieldChanged(Field field, int context)
    {
        if(field==create)
        {
            if(enterText.getText().equals(""))
            {
                QRCodeStartUp.errorHandling("Please Enter Data");
            }
            else
            {
                generateQRCode();                       
            }
        }
    }

    private void generateQRCode()
    {
        try
        {
            QRCode qrCode=new QRCode();
            Encoder.encode(enterText.getText(), ErrorCorrectionLevel.L, qrCode);
            ByteMatrix barcode=qrCode.getMatrix();
            Bitmap bitmap=BarcodeBitmap.createBitmap(barcode, BARCODE_WIDTH);
            barcodeImage.setBitmap(bitmap);
            enterText.setText("");
        }
        catch (Exception e)
        {
            QRCodeStartUp.errorHandling("Exception: "+e.getMessage());
        }   
    }
   
    protected boolean onSavePrompt()
    {
        return true;
    }   
}

Scan Any Type of Barcode Image In Blackberry;

This following class Scans Any type of the Barcode Image which is supports in Blackberry;

Only For Using Version >=6.0
-----------------------------------LoadingScreen.java-------------------------------------

public class LoadingScreen extends MainScreen implements FieldChangeListener
{
    public BarCodeScannerScreen codeScannerView;   
    private LabelField showMessage;
    private ButtonField scan;
    private Font font;
   
    private short _frequency = 1046;
    private short _duration = 200;
    private int _volume = 100;
   
    public LoadingScreen()
    {
        setTitle("BAR CODE Demo");
        font=Font.getDefault().derive(Font.BOLD|Font.ITALIC, 20);
        createGUI();
    }

    private void createGUI()
    {   
        LabelField label=new LabelField("Click The Button To Scan", Field.NON_FOCUSABLE|Field.FIELD_LEADING);
        label.setFont(font);
        label.setPadding(10, 0, 10, 0);
        add(label);
       
        scan=new ButtonField("Scan BARCODE", FIELD_HCENTER);
        scan.setFont(font);
        scan.setChangeListener(this);
        add(scan);
       
        showMessage=new LabelField();
        showMessage.setFont(font);
        showMessage.setPadding(10, 0, 0, 0);
        add(showMessage);
    }

    public void fieldChanged(Field field, int context)
    {
        if(field==scan)
        {
            codeScannerView=new BarCodeScannerScreen(this);
            UiApplication.getUiApplication().pushScreen(codeScannerView);
            codeScannerView.startScan();           
        }
    }
   
    protected void beepSound()
    {
        UiApplication.getUiApplication().invokeLater(new Runnable()
        {
            public void run()
            {               
                Alert.startAudio(new short[]{_frequency, _duration}, _volume);                
            }
        });
    }
   
    public void displayMessage(String text)
    {       
        synchronized (Application.getEventLock())
        {
            UiApplication.getUiApplication().popScreen(codeScannerView);
            showMessage.setText(text);
        }       
    }
   
    protected boolean onSavePrompt()
    {
        return true;
    }
}
-----------------------------------BarCodeScannerScreen .java-------------------------------------
public class BarCodeScannerScreen extends MainScreen
{
    private LoadingScreen qrCodeScanner;
    private BarcodeScanner barcodeScanner;  
  
    public BarCodeScannerScreen(LoadingScreen loadingScreen)
    {
        this.qrCodeScanner=loadingScreen;
        Hashtable hashtable=new Hashtable();      
        Vector formats=new Vector(10);
        formats.addElement(BarcodeFormat.QR_CODE);//In Blackberry These are the supported Formats
        formats.addElement(BarcodeFormat.PDF_417);
        formats.addElement(BarcodeFormat.CODE_128);
        formats.addElement(BarcodeFormat.CODE_39);
        formats.addElement(BarcodeFormat.DATA_MATRIX);
        formats.addElement(BarcodeFormat.EAN_13);
        formats.addElement(BarcodeFormat.EAN_8);
        formats.addElement(BarcodeFormat.ITF);
        formats.addElement(BarcodeFormat.UPC_A);
        formats.addElement(BarcodeFormat.UPC_E);
      
        hashtable.put(DecodeHintType.POSSIBLE_FORMATS, formats);
      
        BarcodeDecoder barcodeDecoder=new BarcodeDecoder(hashtable);
      
        BarcodeDecoderListener barcodeDecoderListener=new BarcodeDecoderListener()
        {
            public void barcodeDecoded(String rawText)
            {
                try
                {
                    qrCodeScanner.beepSound();
                    barcodeScanner.stopScan();
                    qrCodeScanner.displayMessage(rawText);
                }
                catch (Exception e)
                {
                    //Catch The Exception
                }                          
            }         
        };
        try
        {
            barcodeScanner=new BarcodeScanner(barcodeDecoder, barcodeDecoderListener);
            barcodeScanner.getVideoControl().setDisplayFullScreen(true);
            add(barcodeScanner.getViewFinder());                      
        }
        catch (Exception e)
        {
            //Catch The Exception
        }
    }
  
    public void startScan()
    {
        try
        {
            barcodeScanner.startScan();          
        }
        catch (MediaException e)
        {
            //Catch The Exception
        }
    }
  
    protected boolean keyChar(char key, int status, int time)
    {
        if (key == Characters.ESCAPE)
        {
            try
            {
                barcodeScanner.stopScan();
                UiApplication.getUiApplication().popScreen(this);
            }
            catch (MediaException e)
            {
                QRCodeStartUp.errorHandling(e.getMessage());
            }
        }
      
        return super.keyChar(key, status, time);
    }
  
    public void close()
    {
        try
        {
            barcodeScanner.stopScan();
        }
        catch (MediaException e)
        {
            //Catch The Exception
        }
        super.close();
    }
  
    protected boolean onSavePrompt()
    {
        return true;
    }  
}

any doubts feel free to mail on alishaik001@gmail.com 


XMLFileParsing Using DOM In Blackberry

The sample XML file is:

sample.xml:

<ROOT>
<ROW Name="Product Name~B" CheckBox="" Type="PerformanceNormal" Count="1" ChildCount="1" Show="Y" Refine="B">   
   <COL Page="1" Image="" ProductID="3">Sainsbury's aromatherapy citrus mint</COL>
   <COL Page="1" Image="" ProductID="4">TestPerf</COL>      
   <COL Page="2" Image="" ProductID="25">Acb</COL>
</ROW>
<ROW Name="Region~H" CheckBox="" Type="PerformanceNormal" Count="2" ChildCount="1" Show="Y" Refine="H">   
   <COL Page="1" Image="" ProductID="3">Western Europe</COL>  
   <COL Page="1" Image="" ProductID="5">Western Europe</COL>
   <COL Page="1" Image="" ProductID="24">Central and Eastern Europe</COL>   
</ROW>

</ROOT>
--------------------------------
and parse this xml file like:

XMLFileParsingScreen.java :

public class XMLFileParsingScreen extends MainScreen implements FieldChangeListener
{
    private ButtonField domparser;
    public XMLFileParsingScreen() {
        createGUI();
    }
    private void createGUI(){
        domparser=new ButtonField("DOM Parser");
        domparser.setChangeListener(this);
        add(domparser);       
    }
    public void fieldChanged(Field field, int context)
    {
        if(field==domparser)
        {
            ReadAndPrintXMLfileUsingDOM();
        }      
    }
    public void ReadAndPrintXMLfileUsingDOM()
    {

        try {
              DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
              DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
              InputStream rStream = null;
                  try
                  {
                      rStream = getClass().getResourceAsStream("sample.xml");
                  }catch (Exception e)
                  {
                      System.out.println(e.getMessage());
                  }
                  Document doc = docBuilder.parse(rStream);
                  doc.getDocumentElement ().normalize ();
                  System.out.println ("Root element of the doc is " +
                  doc.getDocumentElement().getNodeName());
                NodeList listOfPersons = doc.getElementsByTagName("ROW");
                int totalPersons = listOfPersons.getLength();
                System.out.println("Total no of people : " + totalPersons);
                for(int s=0; s<listOfPersons.getLength() ; s++)
                {
                    Node firstPersonNode = listOfPersons.item(s);
                    Element firstPersonElement = (Element)firstPersonNode;
                    System.out.println( "==============Name value = " + firstPersonElement.getAttribute( "Name" ) );
                    System.out.println( "===============CheckBox value = " + firstPersonElement.getAttribute( "CheckBox" ));
                    System.out.println( "==============Type value = " + firstPersonElement.getAttribute( "Type" ));
                    System.out.println( "==============Count value = " + firstPersonElement.getAttribute( "Count" ));
                    System.out.println( "==============ChildCount value = " + firstPersonElement.getAttribute( "ChildCount" ));
                    System.out.println( "==============Show value = " + firstPersonElement.getAttribute( "Show" ));
                    System.out.println( "==============Refine value = " + firstPersonElement.getAttribute( "Refine" ));
                    NodeList firstNameList = firstPersonElement.getElementsByTagName("COL");
                   
                    int child_lng=firstNameList.getLength();
                    for(int j=0;j<child_lng;j++)
                    {
                            Node innernode=firstNameList.item(j);
                             Element firstPersonElement1 = (Element)innernode;
//                             NamedNodeMap attributes = innernode.getAttributes();
                               Node value=firstNameList.item(j).getChildNodes().item(0);
                             System.out.println( "==============Page value = " + firstPersonElement1.getAttribute( "Page" ) );
                             System.out.println( "==============Image value = " + firstPersonElement1.getAttribute( "Image" ) );
                             System.out.println( "==============ProductID value = " + firstPersonElement1.getAttribute( "ProductID" ) );
                             System.out.println("+++++++++++++++Node Value : " +value.getNodeValue());
                          
                    }
                 }
          }catch (SAXParseException err)
          {
              System.out.println ("** Parsing error" + ", line "
               + err.getLineNumber () + ", uri " + err.getSystemId ());
              System.out.println(" " + err.getMessage ());
          }catch (SAXException e)
          {
              Exception x = e.getException ();
              ((x == null) ? e : x).printStackTrace ();
          }catch (Exception t)
          {
              System.out.println(t.getMessage());
          }
    }
}


any doubts feel free to mail on alishaik001@gmail.com 

Thursday, 12 January 2012

Create Splash Screen in Blackberry

--> The below code shows the Spalsh screen means at the starting time of application you can show some logo/Client's Image for few seconds and then go to the application's main Screen;


//================ StartUp.java=========
 public class StartUp extends UiApplication
{
    public static void main(String[]ali)
    {
        StartUp start=new StartUp();
        start.enterEventDispatcher();
    }
    public StartUp()
    {
        this.pushScreen(new SplashScreen());
        invokeLater(new Runnable()
        {
            public void run()
            {
                try
                {
                    Thread.sleep(2000);
                    pushScreen(new FirstScreen());
                }
                catch (Exception e)
                {
                    exceptionHandling(e.getMessage());
                }
            }
        });
      
    }
  
    public static void exceptionHandling(final String exception)
    {
        UiApplication.getUiApplication().invokeLater(new Runnable()
        {      
            public void run()
            {
                Dialog.alert(exception);
            }
        });
    }
}

//================ SplashScreen.java=========

public class SplashScreen extends MainScreen
{
    Bitmap bitmap=Bitmap.getBitmapResource("loading-screen.png");//This is my company logo;
    BitmapField loadingImage=new BitmapField(bitmap);
    public SplashScreen()
    {
        createGUI();
    }

    private void createGUI()
    {
        try
        {
            VerticalFieldManager vertical=new VerticalFieldManager()
            {
                protected void paint(Graphics g)
                {
                    g.drawBitmap(0, 0,bitmap.getWidth(), bitmap.getHeight(), bitmap, 0, 0);
                    super.paint(g);
                }
                protected void sublayout(int maxWidth, int maxHeight)
                {
                    super.sublayout(Display.getWidth(),Display.getHeight());
                    setExtent(Display.getWidth(),Display.getHeight());
                }
            };
           
//            Nothing to write;
//            Here you can check the some network connections;
//            do somthing;
           
            add(vertical);
        }
        catch (Exception e)
        {
            StartUp.exceptionHandling(e.getMessage());
        }
    }
}


//================ FirstScreen .java========= 

public class FirstScreen extends MainScreen
{       
    VerticalFieldManager vertical;   
   
    public FirstScreen()
    {               
        createGUI();
    }
   
    private void createGUI()
    {
        setTitle("Loading Screen");
        vertical=new VerticalFieldManager()
        {
            protected void sublayout(int maxWidth, int maxHeight)
            {
                super.sublayout(Display.getWidth(),Display.getHeight());
                setExtent(Display.getWidth(),Display.getHeight());
            }
        };
        add(vertical);
    }
   
    public boolean onMenu(int instance)
    {
        return true;
    }
}