Package javax.microedition.content

Examples of javax.microedition.content.Invocation


     if cancelled with {@link #cancelGetRequest cancelGetRequest}
     * @see javax.microedition.content.Registry#invoke
     * @see javax.microedition.content.ContentHandlerServer#finish
     */
    public Invocation getRequest(boolean wait) {
  Invocation request = new Invocation((InvocationImpl)null);
        InvocationImpl invoc = super.getRequest(wait, request);
        if (invoc != null) {
      // Wrap it in an Invocation instance
      request.setInvocImpl(invoc);
      return request;
        }
        return null;
    }
View Full Code Here


     *            objects
     *
     * @see javax.microedition.content.RequestListener#invocationRequestNotify(ContentHandlerServer)
     */
    public void invocationRequestNotify(final ContentHandlerServer server) {
        final Invocation invoc = server.getRequest(false);
        if (invoc != null) {
            if (getActiveScreen() == null) {
                final String type = invoc.getType();

                final DemoMainScreen screen = new DemoMainScreen();
                screen.setTitle("Send Media Demo");

                if (type.equals("audio/mp4") || type.equals("audio/amr")
                        || type.equals("audio/mpeg")) {
                    screen.setType(DemoMainScreen.AUDIO_TYPE);

                    // Play an audio file
                    if (_audioPlayer == null) {
                        final String url = invoc.getURL();
                        screen.add(new LabelField("Playing audio file: " + url));

                        initAudio(url);
                    }
                }

                if (type.equals("image/bmp") || type.equals("image/png")
                        || type.equals("image/jpeg")) {
                    screen.setType(DemoMainScreen.IMAGE_TYPE);

                    // Get data from URL
                    final byte[] data = getData(invoc.getURL());

                    // Create image field
                    final Bitmap image =
                            Bitmap.createBitmapFromBytes(data, 0, -1, 5);
                    final BitmapField imageField =
                            new BitmapField(image, Field.FIELD_HCENTER);

                    screen.add(imageField);
                } else if (type.equals("video/3gpp")
                        || type.equals("video/mp4")) {
                    screen.setType(DemoMainScreen.VIDEO_TYPE);

                    // Play a video
                    initVideo(invoc.getURL());
                    if (_videoField != null) {
                        screen.add(_videoField);

                        try {
                            // Start video player
View Full Code Here

     *
     * @see RequestListener#invocationRequestNotify(ContentHandlerServer)
     */
    public void invocationRequestNotify(final ContentHandlerServer server) {
        // Retrieve Invocation from the content handler server
        final Invocation invoc = server.getRequest(false);

        if (invoc == null) {
            return; // Nothing to do
        }

        int invocationStatus = invoc.getStatus();

        try {
            final Registry registry =
                    Registry.getRegistry(getClass().getName());
            final DefaultContentHandlerRegistry defaultRegistry =
                    DefaultContentHandlerRegistry
                            .getDefaultContentHandlerRegistry(registry);
            final ApplicationDescriptor descriptor =
                    defaultRegistry.getApplicationDescriptor(server.getID());

            Dialog.alert(descriptor.getName() + " invoked for: "
                    + invoc.getURL());

            // ...
            // Other processing could be done here
            // ...

View Full Code Here

    private Invocation getInvocation() {
        // The URL pointing to the location of the file we want to open
        // This file doesn't actually exist.
        final String url = "file:///rim." + DemoContentHandler.SUFFIXES[0];

        final Invocation invoc = new Invocation(url);
        invoc.setType(DemoContentHandler.TYPES[0]);
        invoc.setResponseRequired(false); // We don't require a response

        // We want to invoke a handler that has registered with ACTION_OPEN
        invoc.setAction(DemoContentHandler.ACTIONS[0]);

        return invoc;
    }
View Full Code Here

     * Creates an Invocation object and passes it to the Registry. Called by
     * 'Invoke' menu item.
     */
    private void doInvoke() {
        try {
            final Invocation invoc = getInvocation();

            // Get access to the Registry and pass it the Invocation
            _registry.invoke(invoc);
        } catch (final IOException ioe) {
            errorDialog("Registry#invoke() threw " + ioe.toString());
View Full Code Here

     *
     * @return The new default handler name pulled from the
     *         ApplicationDescriptor
     */
    private String toggleDefaultHandler() {
        final Invocation invocation = getInvocation();
        String newDefaultHandlerName = null;

        try {
            final ContentHandler defaultHandler =
                    _defaultRegistry.getDefaultContentHandler(invocation);
View Full Code Here

                    DemoContentHandler.SUFFIXES, DemoContentHandler.ACTIONS,
                    DemoContentHandler.ID);

            // Get the app name for the current default handler
            try {
                final Invocation invocation = getInvocation();
                final ContentHandler defaultHandler =
                        _defaultRegistry.getDefaultContentHandler(invocation);
                final String id = defaultHandler.getID();
                final ApplicationDescriptor handlerDescriptor =
                        _defaultRegistry.getApplicationDescriptor(id);
View Full Code Here

TOP

Related Classes of javax.microedition.content.Invocation

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.