List of all Iphone and Blackberry Development codes in a one click Iphone,objective C,xcode,blackberry Development,iOS Development

Thursday, March 28, 2013

Application Permissions in Blackberry

BlackBerry Enterprise Server administrators can control the data and APIs that BlackBerry Java Applications can access on BlackBerry devices, and the external data sources and network connections that BlackBerry Java Applications can access by using application control policies. For example, administrators can use application control policies to prevent users from installing an application on a BlackBerry device.
Application control policies enable administrators to perform the following actions:
  • prevent users from installing and running applications on BlackBerry devices
  • limit internal connections (connections behind a firewall)
  • limit external connections
  • limit local connections (serial, infrared, and USB connections)
  • limit access to the key store
  • limit access to particular APIs

You can determine whether an API is available for use on a BlackBerry device and request that the user change permissions, if necessary. In the following code sample, the application checks whether the application control settings permit access to location-based services. If the API is unavailable, the application prompts the user for permission to use this API.

ApplicationPermissionsManager appPermMgr = 
ApplicationPermissionsManager.getInstance();

// Query the Location permission
int locationPermission = appPermMgr.getPermission( 
ApplicationPermissions.PERMISSION_LOCATION_DATA );
        
if( locationPermission != ApplicationPermissions.VALUE_ALLOW ) {

    // Build the permission request
    ApplicationPermissions requestedPermissions = 
        new ApplicationPermissions();

    requestedPermissions.addPermission( 
        ApplicationPermissions.PERMISSION_LOCATION_DATA );

    // Invoke the request, the system takes over            
    appPermMgr.invokePermissionsRequest( requestedPermissions ); 
}
 

Friday, March 22, 2013

TreeField With CheckBox in Blackberry

The following code will help you in creating a TreeField with checkBox.











In Main Screen Class Add the CBTreeField to thhe Screen.

           CBTreeField tree = new CBTreeField("root", false);
            add(tree);
            int ch01 = tree.addChildNode(0, "child 0-1", true, null);
            int ch02 = tree.addChildNode(0, "child 0-2", false, null);
            int ch03 = tree.addChildNode(0, "child 0-3", false, null);
            int ch011 = tree.addChildNode(ch01, "child 0-1-1", false, null);
            int ch012 = tree.addChildNode(ch01, "child 0-1-2", true, null);
            int ch031 = tree.addChildNode(ch03, "child 0-3-1", true, null);

The CBTreeField class is given below -

public class CBTreeField extends VerticalFieldManager implements TreeFieldCallback,
        DrawStyle {
    boolean[] mBooleanValues = new boolean[] {};
    String[] mStringValues = new String[] {};

    public boolean getNodeBooleanValue(int node) {
        return mBooleanValues[node];
    }

    public void setNodeBooleanValue(int node, boolean value) {
        mBooleanValues[node] = value;
    }

    TreeField mRootField = null;

    public CBTreeField(String rootString, boolean rootBoolean) {
        mRootField = new TreeField(this, TreeField.FOCUSABLE);
        add(mRootField);
        mStringValues = insertAt(mStringValues, 0, rootString);
        mBooleanValues = insertAt(mBooleanValues, 0, rootBoolean);
    }

    public int addSiblingNode(int previousSibling, String stringValue,
            boolean booleanValue, Object cookie) {
        int index = mRootField.addSiblingNode(previousSibling, cookie);
        mBooleanValues = insertAt(mBooleanValues, index, booleanValue);
        mStringValues = insertAt(mStringValues, index, stringValue);
        return index;
    }

    public int addChildNode(int parent, String stringValue,
            boolean booleanValue, Object cookie) {
        int index = mRootField.addChildNode(parent, cookie);
        mBooleanValues = insertAt(mBooleanValues, index, booleanValue);
        mStringValues = insertAt(mStringValues, index, stringValue);
        return index;
    }

    static boolean[] insertAt(boolean[] inArray, int index, boolean value) {
        int newLen = inArray.length + 1;
        boolean[] outArray = new boolean[newLen];
        for (int i = 0, j = 0; i < newLen; i++, j++) {
            outArray[i] = (i != index) ? inArray[j] : value;
            if (i == index)
                j++;
        }
        return outArray;
    }

    static String[] insertAt(String[] inArray, int index, String value) {
        int newLen = inArray.length + 1;
        String[] outArray = new String[newLen];
        for (int i = 0, j = 0; i < newLen; i++, j++) {
            outArray[i] = (i != index) ? inArray[j] : value;
            if (i == index)
                j++;
        }
        return outArray;
    }

    public void drawTreeItem(TreeField treeField, Graphics g, int node, int y,
            int width, int indent) {
        String check = String
                .valueOf(mBooleanValues[node] ?
                Characters.BALLOT_BOX_WITH_CHECK : Characters.BALLOT_BOX);
        g.drawText(check, indent, y, DrawStyle.LEFT);
        g.drawText(mStringValues[node], indent + 20, y, DrawStyle.RIGHT
                | ELLIPSIS);
    }

    protected void makeMenu(Menu menu, int instance) {
        super.makeMenu(menu, instance);
        menu.add(new MenuItem("Change value", 0, 0) {
            public void run() {
                int node = mRootField.getCurrentNode();
                mBooleanValues[node] = !mBooleanValues[node];
                invalidate();
            }
        });
    }
}

Wednesday, March 6, 2013

BlackBerry Internet Service (BIS)

The BlackBerry Internet Service is designed to provide users with real-time delivery of email messages, mobile access to attachments, and convenient access to Internet content.

The BlackBerry Internet Service uses the security of the wireless network that it connects to. Email messages that are sent between the BlackBerry Internet Service and a BlackBerry device are not encrypted. When email messages are sent over the wireless network, they are subject to the existing or available network security model(s). However, email messages that are sent between the BlackBerry Internet Service and a messaging server can be encrypted using Secure Sockets Layer (SSL) encryption. SSL encryption can also be used by the BlackBerry® Browser and other applications on a BlackBerry device to help protect data when a user connects to the Internet (for example, while shopping and banking online).
      



        

BlackBerry Enterprise Server (BES)

The BlackBerry Enterprise Server is designed to be a secure, centralized link between an organization's wireless network, communications software, applications, and BlackBerry devices. The BlackBerry Enterprise Server integrates with an organization's existing infrastructure, which can include messaging and collaboration software, calendar and contact information, wireless Internet and intranet access, and custom applications, to provide BlackBerry device users with mobile access to the organization's resources.

The BlackBerry Enterprise Server supports Advanced Encryption Standard (AES) and Triple Data Encryption Standard (Triple DES) encryption to help protect and maintain the integrity of wireless data that is transmitted between the BlackBerry Enterprise Server components and BlackBerry devices. Administrators can choose from more than 450 IT policy rules that they can configure to control the features of the BlackBerry devices that are used in the organization's environment.

The BlackBerry Enterprise Server supports several optional components and configurations to meet the organization's requirements. The BlackBerry Collaboration Service integrates with supported third-party instant messaging servers to permit users to access the organization's instant messaging system from their BlackBerry devices using a BlackBerry instant messaging client. The BlackBerry MDS Integration Service supports custom application development and distribution. Administrators can configure the BlackBerry Enterprise Server and the BlackBerry Enterprise Server components to support high availability to enhance the consistency and reliability of the organization's environment.
  



            

Blackberry Device characteristics

Device characteristicMethod
Identity
simulatorDeviceInfo.isSimulator()
manufacturerDeviceInfo.getManufacturerName()
device nameDeviceInfo.getDeviceName()
PINDeviceInfo.getDeviceId()
IMSISIMCardInfo.getIMSI()
ESNCDMAInfo.getESN()
MEIDCDMAInfo.getHexMEID()
IMEIGPRSInfo.getIMEI()
owner informationOwnerInfo.getOwnerInformation()
owner nameOwnerInfo.getOwnerName()
vendor IDBranding.getVendorId()
branding data versionBranding.getVersion()
is branding data signedBranding.isDataSigned()
Battery
battery level (%)DeviceInfo.getBatteryLevel()
detailed battery informationDeviceInfo.getBatteryStatus()
battery temperature (°C)DeviceInfo.getBatteryTemperature()
battery voltage (mV)DeviceInfo.getBatteryVoltage()
battery removableDeviceInfo.isBatteryRemovable()
Speaker/Headset
audioAudio.isSupported()
codecs supportedAudio.isCodecSupported()
volume level (%)Audio.getVolume()
built-in headsetAudio.hasBuiltInHeadset()
headset connectedAudio.isHeadsetConnected()
Accelerometer
accelerometerAccelerometerSensor.isSupported()
Flip Sensor
flip open or closedSensor.getState()
flipSensor.isSupported()
Holster Sensor
in holsterSensor.getState()
holster sensorSensor.isSupported()
Slide Sensor
sliding keyboardSensor.isSupported()
slide openSensor.isSlideOpened()
slide closedSensor.isSlideClosed()
slide movingSensor.isSlideInTransition()
Display
horizontal resolution (pixels per meter)Display.getHorizontalResolution()
vertical resolution (pixels per meter)Display.getVerticalResolution()
drawable area height (pixels)Display.getHeight()
drawable area width (pixels)Display.getWidth()
number of display colorsDisplay.getNumColors()
subpixels? backlight requiredDisplay.getProperties()
Backlight
backlight onBacklight.isEnabled()
backlight brightness (%)Backlight.getBrightness()
backlight brightness configurableBacklight.isBrightnessConfigurable()
backlight brightness default (%)Backlight.getBrightnessDefault()
default backlight timeout (s)Backlight.getTimeoutDefault()
L.E.D.
LEDLED.isSupported()
multi-color LEDLED.isPolychromatic()
Radios
supported wireless access familiesRadioInfo.getSupportedWAFs()
GPS
GPSGPSInfo.isGPSModeAvailable()
default GPS modeGPSInfo.getDefaultGPSMode()
Bluetooth
BluetoothBluetoothSerialPort.isSupported()
Bluetooth informationBluetoothSerialPort.getSerialPortInfo()
Phone
phone numberPhone.getDevicePhoneNumber()
voice mailPhone.isVoiceMailIndicatorOn()
Memory
flash memory size (bytes)DeviceInfo.getTotalFlashSizeEx()
free flash memory (bytes)Memory.getFlashFree()
get RAM statistics objectMemory.getRAMStats()
OS and software
platform versionDeviceInfo.getPlatformVersion()
software versionDeviceInfo.getSoftwareVersion()
Camera
cameraDeviceInfo.hasCamera()
USB port
USB portUSBPort.isSupported()
USB connection stateUSBPort.getConnectionState()

Programmatically Power OFF Blackberry Device

net.rim.device.api.system.Device.requestPowerOff(true);


        

Tuesday, March 5, 2013

Email Address Validation in Blackberry

 If validateEmailID returns true, then the entered email address is valid.

public static boolean validateEmailID(String email) {
        email = email.trim();
        String reverse = new StringBuffer(email).reverse().toString();
        if (email == null || email.length() == 0 || email.indexOf("@") == -1) {
            return false;
        }
        int emailLength = email.length();
        int atPosition = email.indexOf("@");
        int atDot = reverse.indexOf(".");

        String beforeAt = email.substring(0, atPosition);
        String afterAt = email.substring(atPosition + 1, emailLength);

        if (beforeAt.length() == 0 || afterAt.length() == 0) {
            return false;
        }
        for (int i = 0; email.length() - 1 > i; i++) {
            char i1 = email.charAt(i);
            char i2 = email.charAt(i + 1);
            if (i1 == '.' && i2 == '.') {
                return false;
            }
        }
        if (email.charAt(atPosition - 1) == '.' || email.charAt(0) == '.' || email.charAt(atPosition + 1) == '.' || afterAt.indexOf("@") != -1 || atDot < 2) {
            return false;
        }

        return true;
    }