Simples Assim

Posts Tagged ‘BlackBerry

What Is – Supported versions of BlackBerry Device Software for the BlackBerry App World storefront

leave a comment »

Written by Fernando Ribeiro

July 28, 2010 at 9:34 pm

Posted in Business, Software, Technology

Tagged with

How to Validate Fields in BlackBerry API 4.2.0+

leave a comment »

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.FullScreen;

public final class SampleScreen extends FullScreen {
  private Field button;

  private Field text;

  public SampleScreen(final long style) {
    text = new BasicEditField() {

      public boolean isDataValid() {
        return getTextLength() > 0; // Can't be empty
      }

    };

    button = new ButtonField("Validate");

    button.setChangeListener(new FieldChangeListener() {

      public void fieldChanged(final Field field, final int context) {

        if (text.isDataValid()) {
          ...
        } else {
          Dialog.alert("This field is required!");
        }

      }

    });
  }

}

http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/ui/Field.html#isDataValid()

Written by Fernando Ribeiro

July 25, 2010 at 3:39 am

Posted in Software

Tagged with

How to Round Numbers in BlackBerry API 4.6.0+

leave a comment »

Use MathUtilities.round, there isn’t Math.round in Java ME.

Written by Fernando Ribeiro

July 25, 2010 at 3:19 am

Posted in Software

Tagged with

BlackBerry UI Field Reference

leave a comment »

Written by Fernando Ribeiro

July 25, 2010 at 2:52 am

Posted in Software

Tagged with

Creating Custom Field Managers in BlackBerry

leave a comment »

Written by Fernando Ribeiro

July 25, 2010 at 2:50 am

Posted in Software

Tagged with

Split-Pipe Connections in BlackBerry

leave a comment »

Written by Fernando Ribeiro

July 19, 2010 at 12:30 am

Posted in Software

Tagged with

Improvement to BlackBerry API 5.0.0

leave a comment »

Written by Fernando Ribeiro

July 18, 2010 at 11:54 pm

Posted in Software

Tagged with

Improvement to BlackBerry API 5.0.0

leave a comment »

Written by Fernando Ribeiro

July 18, 2010 at 11:30 pm

Posted in Software

Tagged with

Localizing BlackBerry Applications

leave a comment »

Written by Fernando Ribeiro

July 18, 2010 at 10:48 pm

Posted in Software

Tagged with

How to Trigger Notifications in BlackBerry API 3.6+

leave a comment »

Application

package br.eti.fernandoribeiro.sample.ui;

import net.rim.device.api.i18n.ResourceBundle;
import net.rim.device.api.notification.NotificationsConstants;
import net.rim.device.api.notification.NotificationsManager;
import net.rim.device.api.ui.UiApplication;

import br.eti.fernandoribeiro.sample.notifications.SampleConsequence;
import br.eti.fernandoribeiro.sample.util.Constants;
import br.eti.fernandoribeiro.sample.util.SampleResource;

public final class SampleApplication extends UiApplication {
  private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(SampleResource.BUNDLE_ID, SampleResource.BUNDLE_NAME);

  public static void main(final String[] args) {
    NotificationsManager.registerSource(Constants.SOURCE_SAMPLE, BUNDLE.getString(SampleResource.APPLICATION_TITLE), NotificationsConstants.DEFAULT_LEVEL);

    NotificationsManager.registerConsequence(Constants.CONSEQUENCE_SAMPLE, new SampleConsequence());
    ...
    NotificationsManager.triggerImmediateEvent(Constants.SOURCE_SAMPLE, Constants.EVENT_SAMPLE, null, null); // May be anywhere in the app
    ...
  }

  ...
}

Consequence

package br.eti.fernandoribeiro.notifications;

import net.rim.device.api.notification.Consequence;
import net.rim.device.api.synchronization.SyncConverter;
import net.rim.device.api.synchronization.SyncObject;
import net.rim.device.api.system.LED;
import net.rim.device.api.util.DataBuffer;

import br.eti.fernandoribeiro.util.Constants;

public final class SampleConsequence implements Consequence, SyncConverter {

  public SyncObject convert(final DataBuffer arg0, final int arg1, final int arg2) {
    return null;
  }

  public boolean convert(final SyncObject arg0, final DataBuffer arg1, final int arg2) {
    return false;
  }

  public Object newConfiguration(final long consequenceID, final long sourceID, final byte profileIndex, final int level, final Object context) {
    return new Object(); // Can't be null
  }

  public void startNotification(final long consequenceID, final long sourceID, final long eventID, final Object configuration, final Object context) {

    if ((Constants.CONSEQUENCE_SAMPLE == consequenceID) && (Constants.SOURCE_SAMPLE == sourceID) && (Constants.EVENT_SAMPLE == eventID))
      LED.setState(LED.STATE_BLINKING);

  }

  public void stopNotification(final long consequenceID, final long sourceID, final long eventID, final Object configuration, final Object context) {

    if ((Constants.CONSEQUENCE_SAMPLE == consequenceID) && (Constants.SOURCE_SAMPLE == sourceID) && (Constants.EVENT_SAMPLE == eventID))
      LED.setState(LED.STATE_OFF);

  }

}

Constants (Recommended)

package br.eti.fernandoribeiro.sample.util;

public interface Constants {
  long CONSEQUENCE_SAMPLE = 0xcdb9b62f62f4dccdL; // Global

  long EVENT_SAMPLE = 0x35b82a6314580fffL; // Global

  long SOURCE_SAMPLE = 0L; // Application-specific
}

http://c2.com/ppr/wiki/JavaIdioms/InterfacesForDefiningConstants.html

Written by Fernando Ribeiro

July 18, 2010 at 10:34 pm

Posted in Software

Tagged with