Archive for the ‘Tutorials’ Category

Brand new BlackBerry Torch 9800 Buggy

So you just bought a brand new BlackBerry Torch and it is doing things like having trouble opening the browser, web pages are strangely mirrored and random 10 seconds of non-responsiveness. My Torch was purchased at release, and worked really well, until an upgrade came out for it. I eventually got so frustrated I downgraded the OS back to the original release OS.

To see if you are in this position:

1) Go to Homescreen. While holding alt type “e s c r”.

2) if your AppVersion is 6.0.0.246 (695) , Stop reading this page, its useless to you.

3) If it is: 6.0.0.448, And you are frustrated, you may want to try downgrading or upgrading. Since I know the downgrade software is pretty stable (I use it), I suggest downgrading. If you want to take a chance that the upgrade is even better, try it out. It is the Rogers download at Applications version 6.0.0.600

Of course, you’ll need an installation of Desktop Manager

To downgrade, go to this website and select your carrier. I am familiar with Telus and Rogers and thus will explain from that point of view.

You have two options at this point, you can go to the Rogers page and upgrade to 6.0.0.600 or select either Rogers or Telus and download the 6.0.0.246 bundle. It should not matter that you select software from a different carrier for the most part. The biggest difference is that different carriers will request some features be not included or additional features included in their bundles. Otherwise they are exactly the same.

After downloading this, install it, and restart your computer. Open desktop manager with your BlackBerry plugged into your computer, and the “Device” menu in the top left. Click “Update My Device” and when a popup explains that you have “No BlackBerry Device Software updates available”  click on the “View other Versions” button in the bottom left of the popup.

In the list should be the version we want, and follow the instructions from this point, making sure that if something asks you whether you want to backup, select yes. Often times I will back up my device myself before doing any OS changes. This is of course in the “Device” dropdown menu, selecting “Back up”.

 

For pretty pictures of the process go here

 

A Basic Error Logging Class

This should help make BlackBerry application error logging easier. To see your event-log you can type Alt+LGLG on your home screen. You can also use javaloader.exe (comes in the bin folder of the JDE) to export the log to a text file.

Javaloader -u eventlog > textfile.txt

Using the class below, you must change the unique bundle ID and name to match your application. This can be done for you when you add any new resource file to your project. Within the class used to access the resource strings will be BUNDLE_ID and BUNDLE_NAME. Replace those values in the class below.

Download the class below:

Logger.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package ca.dftr.lib.error;
 
/*
 * Logger.java
 */
import net.rim.device.api.system.EventLogger;
import ca.dftr.lib.resources.libResource;
 
public class Logger {
 
	public static int LEVEL_INFO = EventLogger.INFORMATION;
	public static int LEVEL_WARNING = EventLogger.WARNING;
	public static int LEVEL_ERROR = EventLogger.ERROR;
	public static int LEVEL_SEVERE_ERROR = EventLogger.SEVERE_ERROR;
 
	public static String LOG_PREFIX_INFO = "Info: ";
	public static String LOG_PREFIX_WARN = "Warning: ";
	public static String LOG_PREFIX_ERROR = "Error: ";
	public static String LOG_PREFIX_SEVERE = "Severe Error: ";
 
	//Must put in your unique bundle ID and name.
	static {
		EventLogger.register(libResource.BUNDLE_ID, libResource.BUNDLE_NAME, EventLogger.VIEWER_STRING);
	}
 
	public static void logEventInfo(String eventData) {
		Logger.logEvent(Logger.LEVEL_INFO, Logger.LOG_PREFIX_INFO + eventData);
	}
 
	public static void logEventWarn(String eventData) {
		Logger.logEvent(Logger.LEVEL_WARNING, Logger.LOG_PREFIX_WARN + eventData);
	}
 
	public static void logEventError(String eventData) {
		Logger.logEvent(Logger.LEVEL_ERROR, Logger.LOG_PREFIX_ERROR + eventData);
	}
 
	public static void logEventSevere(String eventData) {
		Logger.logEvent(Logger.LEVEL_SEVERE_ERROR, Logger.LOG_PREFIX_SEVERE + eventData);
	}
 
	/**
	 * Log Event.
	 * Note: The event will only end up in the log depending on the
	 * EventLogViewer min log level. Accessed via alt+LGLG on home screen
	 */
	public static void logEvent(int level, String eventData) {
		EventLogger.logEvent(libResource.BUNDLE_ID, eventData.getBytes(), level);
		System.out.println(eventData);
	}
}

Change Color of Font in BlackBerry LabelField

In a previous post I linked the ColoredLabelField.java class. This class has replaced all of my LabelFields. I forget where I got the details from (probably stack overflow) though its been changed since then. Either way, this is how you change font color of a UI element on BlackBerry. Figured this is a pretty basic thing that I may as well make easier to find.

ColoredLabelField.java

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package ca.dftr.calendar.ui.components;
 
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.LabelField;
 
/**
 * Creates a label field with a custom font color
 * @author deforbes, ...
 */
public class ColoredLabelField extends LabelField {
 
	/**
	 * ColoredLabelField constructor
	 * @param text Text to be contained within the field
	 * @param style LabelField modifiers (i.e. ColoredLabelField.FIELD_LEFT | ColoredLabelField.HIGHLIGHT_SELECT)
	 */
	public ColoredLabelField(String text, long style) {
		super(text, style); 
	}
 
	/**
	 * ColoredLabelField color constructor
	 * @param text Text to be contained within the field
	 * @param style LabelField modifiers (i.e. ColoredLabelField.FIELD_LEFT | ColoredLabelField.HIGHLIGHT_SELECT)
	 * @param color Font color (i.e. Color.BLACK)
	 */
	public ColoredLabelField(String text, long style, int color) {
		super(text, style);
		_fontColor = color;
	}
	private int _fontColor = -1;
 
	/**
	 * Set the LabelFields font color
	 * @param fontColor Font's Color
	 */
	public void setFontColor(int fontColor) {
		_fontColor = fontColor;
	}
 
	/**
	 * Get Font's Color
	 * @return Color bit.
	 */
	public int getFontColor(){
		return _fontColor;
	}
 
	protected void paint(Graphics graphics) {
		if (-1 != _fontColor)
			graphics.setColor(_fontColor);
		super.paint(graphics);
	}
}
Return top

INFORMATION

I do not adhere to a schedule. I post when I have something to say. I'm a programmer who in my spare time enjoys contemplating the meaning of life, the universe and, everything. So there will be code as well as random little stories, essays and, musing about whatever interests me at the moment.