Guest Book
What people have said about the book:
I have been thinking a lot about what you said about the book not being a "learning Java" book and I think (for me at least) that will be perfect. The Java part, aside from the nuances, is pretty much like C#, etc.... Throw in the RIM API and it's not a huge deal to learn. However, learning it completely and properly obviously will take some time. The stuff you mention, MDS etc..., will be the very topics I will need for sure come time for the release of your book.
Rich Friedel |
|
|
|
|
Chapter 11 includes a sample BlackBerry Java application that demonstrates how to use the methods available in the Sensor class (net.rim.device.api.system.Sensor) to obtain information about a BlackBerry device. Here's the code:
package com.bbdevfundamentals.SensorTest;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.system.Application;
import net.rim.device.api.system.SensorListener;
import net.rim.device.api.system.Sensor;
//Create the HelloWorld class
public class SensorTest extends UiApplication implements SensorListener {
public static void main(String[] args) {
// Instantiate the HelloWorld object
SensorTest st = new SensorTest();
// Enter the Event Dispatcher
st.enterEventDispatcher();
}
public SensorTest() {
// Create the HelloWorldScreen and open it
pushScreen(new SensorTestScreen());
Sensor.addListener(Application.getApplication(), this, Sensor.HOLSTER);
}
public void onSensorUpdate(int sensorId, int update) {
if (update == Sensor.STATE_IN_HOLSTER) {
Dialog.alert("Device is holstered");
} else {
Dialog.alert("Device is not holstered");
}
}
}
final class SensorTestScreen extends MainScreen {
public SensorTestScreen() {
super();
// Create the screen's title
LabelField lblTitle = new LabelField("Sensor Test", LabelField.ELLIPSIS
| LabelField.USE_ALL_WIDTH);
setTitle(lblTitle);
}
}
I wrote a little bit about this application over at www.johnwargo.com, I had an application that used DeviceInfo.isInHolster() and all of a sudden it stopped working in the 4.7JDE. I had to learn a different way to do it and decided to add it to the book.
|
|
|