Skip to main content

Posts

Showing posts with the label BlackBerry

How to connect to Internet Using Blackberry

In the blackberry there are many standard connection methods. BES/MDS Direct TCP WiFi But in these methods some times will not work on all the careers so their is a another undocumented method that you  can use. package com.rdmcorp.itms.sdm.DataService; import net.rim.device.api.servicebook.ServiceBook; import net.rim.device.api.servicebook.ServiceRecord; import net.rim.device.api.system.CoverageInfo; import net.rim.device.api.system.DeviceInfo; import net.rim.device.api.system.WLANInfo; public class ConnectionCreator { public static String getConnectionString() throws ServerException { String connectionString = null; // Simulator behavior is controlled by the USE_MDS_IN_SIMULATOR variable. if (DeviceInfo.isSimulator()) { connectionString = ";deviceside=true" ; } // Wifi is the preferred transmissio...

Change the background color in Blackberry Fields

There are four basic background available in blackberry. SolidBackground SolidBackgroundwithTranparency GradientBackground BitmapBackground // Solid Background Background b=BackgroundFactory.createSolidBackground(Color.ANTIQUEWHITE); setBackground(b);   // Solid Background with Transperancy //Alpha Background b=BackgroundFactory.createSolidTransparentBackground(Color.AZURE,180); setBackground(b);   // Gradient Background Background b = BackgroundFactory.createLinearGradientBackground( Color.AZURE,Color.BISQUE,Color.AZURE, Color.BISQUE); setBackground(b);   // Bitmap Background Background b = BackgroundFactory.createBitmapBackground(yourImage, 0, 0,0); setBackground(b);

Programmatically Read JAD file in Blackberry

in here following code worked but you have to deploy the application using JAD file (download through the web)  not the using alx file. public static String getJADProperty(String Name){ CodeModuleGroup[] allGroups = CodeModuleGroupManager.loadAll(); CodeModuleGroup myGroup = null; String moduleName= "" ; moduleName = ApplicationDescriptor.currentApplicationDescriptor().getModuleName(); for ( int i = 0; i < allGroups.length; i++) { if (allGroups[i].containsModule(moduleName)) { myGroup = allGroups[i]; break ; } }   // Get the property String prop = myGroup.getProperty(Name); return prop; } You can get the custom property by calling // You can get the MyTag:something String value = getJADProperty( "MyTag" )

Asynchronous Threading in Blackberry

Assume that you are having a class called Class A it needs to call Class Z as a thread. Therefore you can  implement class Z from Runnable interface and implement your code in run(). Ex:- public class ClassZ implements Runnable {   public static final int METHOD1 =1; public static final int METHOD2= 2;   int code; public ClassZ( int code) { this .code=code; }   private void method1() { //Code for Method1 }   private void method2() { //Code for Method2 }   public void run() { switch (code) { case ClassZ.METHOD1 : method1(); break ; case ClassZ.METHOD2: method2(); break ; } }   public void runThread() { thread = new Thread( this ); thread.start(); } } If you start the Thread using ClassZ it runs ClassZ’s run method. Therefore  if you have several method...

Change APN Setting programmatically in Blackberry

As shown bellow you want to set APN and Username (optional),Password (optional) in your connection programmatically, if you are not set it in the device. This also caused to Tunnel Failed error. public String HttpGET(String Url) { String AppendURL = ";deviceside=true ;apn=internet.com" ; AppendURL += ";tunnelauthusername=user165;tunnelauthpassword=user165password" ; try { HttpConnection httpConnection = (HttpConnection) Connector.open(Url+AppendURL); httpConnection.setRequestMethod(HttpConnection.GET); InputStream inputStream = httpConnection.openInputStream(); StringBuffer sb = new StringBuffer(); int C; while ( -1 != (C = inputStream.read())) { sb.append(( char )C); }   return sb.toString(); } catch (Exception e) { return "" ; } }

How to save server certificate to blackberry key store

First you have to download the certificate file manually. To do this open your Firefox browser and type the URL which enables SSL. Then you can see a Padlock bottom of the browser. Double click the pad clock . then you can see the certificate window. Click View Certificate button. In the certificate viewer window select Details Tab and select Export button. Then Save your Certificate as X.509 (PEM) format.  You will get this kind of file. Open eclipse and Create new Blackberry Project. Copy Certificate file in to the same package that class created. (In here I'm writing my code in Main.java class thus i copied the certificate file in to Main package.) Following shows code sample public Certificate ReadFile() { try { Class classs = Class.forName( "com.ironone.main.Main" ); InputStream is = classs.getResourceAsStream( "/DigiCertEVRootCA.crt" ); // Certificate File Name :DigiCertEVRootCA.crt byte [] data = new byte [is.available()]; is.read(dat...