Package net.rim.blackberry.api.invoke

Examples of net.rim.blackberry.api.invoke.MapsArguments


        Invoke.invokeApplication( Invoke.APP_TYPE_CAMERA, args );
    }

    private void invokeMaps( final Object arg ) throws Exception {
        MapsArguments args = null;

        if( arg instanceof MapsArgumentsObject ) {
            final MapsArgumentsObject m = (MapsArgumentsObject) arg;

            if( m.isDefault() ) {
                args = new MapsArguments();
            } else {
                // Populate location string from document
                final String xml = m.getXML();
                if( xml != null ) {
                    args = new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, xml );
                } else {
                    // Populate location string from address
                    final AddressObject addressObject = m.getAddressObject();
                    if( addressObject != null ) {
                        final String locality = addressObject.getItem( AddressObject.FIELD_CITY ).getStringValue();
                        final String region = addressObject.getItem( AddressObject.FIELD_STATE ).getStringValue();

                        if( locality.length() > 0 && region.length() > 0 ) {
                            Contact c;

                            // Create a new contact
                            try {
                                final ContactList contactList = (ContactList) PIM.getInstance().openPIMList( PIM.CONTACT_LIST,
                                        PIM.READ_WRITE );
                                c = contactList.createContact();
                            } catch( final PIMException e ) {
                                throw e;
                            }

                            final String[] addressHome = new String[ 7 ];
                            addressHome[ Contact.ADDR_STREET ] = addressObject.getItem( AddressObject.FIELD_ADDRESS1 )
                                    .getStringValue();
                            addressHome[ Contact.ADDR_LOCALITY ] = addressObject.getItem( AddressObject.FIELD_CITY )
                                    .getStringValue();
                            addressHome[ Contact.ADDR_REGION ] = addressObject.getItem( AddressObject.FIELD_STATE )
                                    .getStringValue();
                            addressHome[ Contact.ADDR_POSTALCODE ] = addressObject.getItem( AddressObject.FIELD_ZIP )
                                    .getStringValue();
                            addressHome[ Contact.ADDR_COUNTRY ] = addressObject.getItem( AddressObject.FIELD_COUNTRY )
                                    .getStringValue();
                            addressHome[ Contact.ADDR_EXTRA ] = addressObject.getItem( AddressObject.FIELD_ADDRESS2 )
                                    .getStringValue();

                            c.addStringArray( Contact.ADDR, Contact.ATTR_HOME, addressHome );
                            args = new MapsArguments( c, 0 );
                        } else {
                            throw new IllegalArgumentException( "Address should contain 'city' and 'state' information!" );
                        }
                    } else {
                        // Populate location string from coordinate
                        final long lat = (long) ( m.getLatitude() * 100000 );
                        final long lon = (long) ( m.getLongitude() * 100000 );
                        final String locationCoordinate = "<lbs clear='ALL'>" + "<location lon='" + new Long( lon ).toString()
                                + "' lat='" + new Long( lat ).toString() + "'/>" + "</lbs>";
                        args = new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, locationCoordinate );
                    }
                }
            }
        } else {
            args = new MapsArguments();
        }

        Invoke.invokeApplication( Invoke.APP_TYPE_MAPS, args );
    }
View Full Code Here


                mapview.setLongitude(-7569792);
                mapview.setZoom(3);

                // Invoke maps application with specified MapView
                Invoke.invokeApplication(Invoke.APP_TYPE_MAPS,
                        new MapsArguments(mapview));
            }
        }));

        addMenuItem(viewMapItem);
    }
View Full Code Here

                // Invoke the BlackBerry Maps application with the
                // chosen location.
                if (_mapsPresent) {
                    final Landmark[] landmark = { location };
                    final MapsArguments mapsArgs = new MapsArguments(landmark);
                    Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, mapsArgs);
                }
            }
        }
View Full Code Here

                    _mapview.setLongitude(longitude);

                    // Invoke BlackBerry Maps application with provided MapView
                    // object.
                    Invoke.invokeApplication(Invoke.APP_TYPE_MAPS,
                            new MapsArguments(_mapview));

                    close();
                } catch (final RuntimeException re) {
                    // An exception is thrown when any of the following occur :
                    // Latitude is invalid : Valid range: [-90, 90]
View Full Code Here

                document.append("' label='MyLocation' zoom='");
                document.append(_zoomLevelField.getText());
                document.append("'/></lbs>");

                Invoke.invokeApplication(Invoke.APP_TYPE_MAPS,
                        new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT,
                                document.toString()));
            } catch (final Exception e) {
                log("Unable to map Location. Please make sure that BlackBerry Maps is installed.");
            }
        }
View Full Code Here

            final Landmark[] landmark =
                    { new Landmark(_dataObject.getName(), null, null, address) };

            // Invoke the Maps application with the address in the data object
            Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(
                    landmark));
        }
View Full Code Here

                document.append(_zoomLevelField.getText());
                document.append("'/></lbs>");

                // Launch Maps application
                Invoke.invokeApplication(Invoke.APP_TYPE_MAPS,
                        new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT,
                                document.toString()));
            } catch (final Exception e) {
                log("Unable to map Location. Please make sure that BlackBerry Maps is installed.");
            }
        }
View Full Code Here

             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                // Invoke maps application with default map
                Invoke.invokeApplication(Invoke.APP_TYPE_MAPS,
                        new MapsArguments());
            }
        }));

        addMenuItem(viewMapItem);
    }
View Full Code Here

                            if (address[Contact.ADDR_LOCALITY] != null
                                    && address[Contact.ADDR_REGION] != null) {
                                // Invoke maps application for current Contact
                                Invoke.invokeApplication(Invoke.APP_TYPE_MAPS,
                                        new MapsArguments(c, 0));
                                foundAddress = true;
                            }
                        }
                    }
                } catch (final PIMException e) {
                    UiApplication.getUiApplication().invokeLater(
                            new Runnable() {
                                public void run() {
                                    Dialog.alert("PIM#openPIMList() threw PIMException");
                                }
                            });
                }

                // Invoke maps application with default map
                if (!foundAddress) {
                    Invoke.invokeApplication(Invoke.APP_TYPE_MAPS,
                            new MapsArguments());
                }
            }
        }));

        addMenuItem(viewMapItem);
View Full Code Here

            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                final String document =
                        "<lbs clear='ALL'><location lon='-7938675' lat='4367022' label='Toronto, ON' description='Go Leafs Go!' zoom='10'/></lbs>";
                Invoke.invokeApplication(Invoke.APP_TYPE_MAPS,
                        new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT,
                                document));
            }
        }));

        // Displays multiple locations on a map
        final MenuItem viewMultipleItem =
                new MenuItem(new StringProvider("View Multiple Locations"),
                        0x230020, 1);
        viewMultipleItem.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                final StringBuffer stringBuffer =
                        new StringBuffer("<lbs clear='ALL'>");
                stringBuffer
                        .append("<location lon='-8030000' lat='4326000' label='Kitchener, ON' description='Kitchener, Ontario, Canada' />");
                stringBuffer
                        .append("<location lon='-7569792' lat='4542349' label='Ottawa, ON' description='Ottawa, Ontario, Canada' />");
                stringBuffer.append("</lbs>");

                Invoke.invokeApplication(Invoke.APP_TYPE_MAPS,
                        new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT,
                                stringBuffer.toString()));
            }
        }));

        addMenuItem(viewSingleItem);
View Full Code Here

TOP

Related Classes of net.rim.blackberry.api.invoke.MapsArguments

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.