Saturday, February 14, 2009

News : RIM issues security patch alongside Certicom buyout

0 comments

RIM has issued a security patch for the BlackBerry. The update applies to the Application Web Loader and is related to Microsoft’s recent security updates to Internet Explorer 7. Apparently, the ActiveX component is vulnerable to a memory overflow error which, if exploited, could allow an attacker to remotely execute code on a targeted system. This patch has come in conjunction with the Certicom buyout and rounds out their security efforts quite nicely. Thanks RIM for making our BlackBerrys that much safer.

Friday, February 13, 2009

News: T-Mobile and RIM make the BlackBerry 8900 Curve official, coming in February

0 comments

Waterloo, Ontario – January 7, 2009 – T-Mobile USA, Inc., and Research In Motion (RIM) (Nasdaq: RIMM: TSX: RIM) today announced that T-Mobile® will offer its customers the new BlackBerry® Curve™ 8900 smartphone, the thinnest and lightest full-QWERTY BlackBerry smartphone.
The BlackBerry Curve 8900 from T-Mobile, in a stunning titanium-colored finish with chrome highlights, combines an elegant, compact design with a wide range of popular features and an easy-to-use full-QWERTY keyboard. It features built-in GPS and support of location-based services. It also allows easy access to social networking sites and has built-in Wi-Fi® (802.11 b/g) supporting both voice and data, making it easier to stay connected to family, friends and colleagues.
“T-Mobile is thrilled to bring our customers such an elegant and powerful way to communicate with the important people in their lives,” said Travis Warren, director, device marketing, T-Mobile USA. “The BlackBerry Curve 8900 offers T-Mobile customers the benefit of a full-QWERTY keyboard in the thinnest BlackBerry smartphone yet.”

Thursday, February 12, 2009

Code: soft reboot BlackBerry device by coding

1 comments

Here is the sample code to soft reboot the blackberry device using codes :


public static final void powerCycle (int delayToPowerOn) {
int timeDelay = 1000 * delayToPowerOn;
ApplicationManager myMgr = ApplicationManager.getApplicationManager();
ApplicationDescriptor myDsc = ApplicationDescriptor.currentApplicationDescriptor();

// myMgr.setCurrentPowerOnBehavior(myDsc.POWER_ON);

Date myDate = new Date();

myMgr.scheduleApplication(myDsc, myDate.getTime()+timeDelay, true);
net.rim.device.api.system.Device.requestPowerOff( true);

}

Monday, February 2, 2009

How to - Capture power change events

0 comments

Your application can be notified when power change events take place on the BlackBerry device. This could be used to halt certain features when the battery power is low, and resume them when it is back to normal levels. Implementing the SystemListener interface (net.rim.device.api.system.SystemListener) can perform these operations. Events such as the BlackBerry powering on, powering off, and changes in the battery state can be captured. The following sample application shows how to implement the SystemListener interface:
Code:
/**
* PowerChangeEvent.java
*
*/

import java.util.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;

public class PowerChangeEvent
extends Application implements SystemListener
{
public static PowerChangeEvent theApp;

public static void main(String args[])
{
theApp = new PowerChangeEvent();
theApp.enterEventDispatcher();
}

public PowerChangeEvent()
{
//Register this instance with the system listener.
Application.getApplication().addSystemListener(this);
System.out.println("PowerChangeEvent: PowerChangeEvent has started!");
}

//Invoked when the user is putting the device into a power off state.
public void powerOff()
{
System.out.println("PowerChangeEvent: The BlackBerry is powering off.");
}

//Invoked when the device has left the power off state.
public void powerUp()
{
System.out.println("PowerChangeEvent: The BlackBerry is powering up.");
}

//Invoked when the internal battery voltage falls below a critical level.
public void batteryLow()
{
System.out.println("PowerChangeEvent: The battery is getting low!");
}

//Invoked when the internal battery voltage has returned to normal.
public void batteryGood()
{
System.out.println("PowerChangeEvent: The battery level is now good!");
}

//Invoked when the internal battery state has changed.
//Not used in this sample.
public void batteryStatusChange(int status)
{
}
}

How to - Detect system availability on startup

0 comments

The best way to ensure that the system is available and ready is to leverage the ApplicationManager class with its inStartup method along with using a system listener and its powerUp method. Sample code is included below as an example on how you can detect when the system is available and ready.
Code:
public static void main( String[] args ) {
// Perform additional work as part of main method if necessary.
if( ApplicationManager.getApplicationManager().inStartup() ) {
// Add a system listener to detect when system is ready and available.
applicationInstance.addSystemListener( applicationInstance );
} else {
// System is already ready and available so perform your start up work
now.
// Note that this work must be completed using invokeLater because the
// application has not yet entered the event dispatcher.
applicationInstance.doStartupWorkLater();
}
// Enter the event dispatcher.
applicationInstance.enterEventDispatcher();
}
/**
* Implementation of the powerUp method for the SystemListener interface
*
*/
public void powerUp()
{
applicationInstance.removeSystemListener( this );
doStartupWork();
}
/**
* Perform the start up work on a new Runnable using the
* invokeLater construct to ensure that it is executed
* after the event thread has been created.
*
*/
private void doStartupWorkLater()
{
applicationInstance.invokeLater( new Runnable() {
public void run() {
doStartupWork();
}
} );
}
/**
* Your private method for performing your startup work.
*
*/
private void doStartupWork()
{
// Perform your start up activities here!
}

How To - Launch a third party application from another third party application

0 comments

On the handheld, you can launch a third party application from another third party application. The code sample below demonstrates how this can be done.
Code:
int modHandle = CodeModuleManager.getModuleHandle("MyApplication");
ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle);
ApplicationManager.getApplicationManager().runApplication(apDes[0]);


An application can also schedule another application to be launched at a specific time. This can be done through the use of the ApplicationManager.scheduleApplication method.

What Is - The reason a reset is required when upgrading an application

0 comments
When performing an application upgrade over the wireless network, the BlackBerry device user may be prompted to restart the BlackBerry device for the upgrade to complete. The application developer has minimal influence over whether or not a reset is required, other than to completely terminate the application prior to performing the upgrade. In general, no action is required from the application developer because these reset prompts are normal for the BlackBerry device and provide a clean operating environment.

The following list provides the most common causes for BlackBerry device reset prompts when upgrading an application:

1. An application thread is running from one of the COD files to be updated.
2. The application defines a dependency between a native class and one of its classes, possibly by a listener.
3. The application contains a live reference to a large array or large String that cannot be copied.
4. The application contains a live reference to a transient object.
5. The application contains a live reference to a persistent object.
6. The virtual machine (VM) detects another application's dependence on one of the application's COD files, possibly by a COD file defined as a library.
7. The application is very large and/or contains many sibling COD files, resulting in the need for some complex linking operations that are only performed during startup.

Tuesday, January 27, 2009

Code: Image Scaling in J2ME

1 comments

This function scales images using an optimized form of bresenham's formula. You can also add bilinear sampling and such to it but I figured since it's on a cell phone it won't matter much and will also cause it to be slower.







public static Image scaleImage( Image original, int newWidth,

int newHeight) {


int[] rawInput = new int[original.getHeight()


* original.getWidth()];


original.getRGB(rawInput, 0, original.getWidth(), 0, 0,


original.getWidth(), original.getHeight());


int[] rawOutput = new int[newWidth * newHeight];


// YD compensates for the x loop by substracting the width


//back out.


int YD = (original.getHeight() / newHeight)


* original.getWidth() – original.getWidth();


int YR = original.getHeight() % newHeight;


int XD = original .getWidth() / newWidth;


int XR = original.getWidth() % newWidth;


int outOffset = 0;


int inOffset = 0;


for (int y= newHeight, YE= 0, y > 0; y--) {


for (int x= newWidth, XE= 0; x > 0; x--) {


rawOutput[outOffset++] = rawInput[inOffset];


inOffset += XD;


XE += XR;


if (XE >= newWidth) {


XE –= newWidth;


inOffset++;


}


}


inOffset += YD;


YE += YR;


if (YE >= newHeight) {


YE –= newHeight;


inOffset += original.getWidth();


}


}


return Image.createRGBImage(rawOutput, newWidth, newHeight, false);


}