Application of background visible on a real device (all well in the Simulator)

Hello

I developed a small backgroundapplication, which shows a menu entry in the app phone "call via Asterisk. If I choose this option a defined number is called. Later, I want to add the number as dtmf tones.

The application uses excactly as expected in the device Simulator 8310-JDE (included in the eclipse plugin) on JDE 4.5. with eclipse.

But when I deploy the application (signed) to a real 8310 with firmeware v4.5.0.81, it appears an application icon on the desktop (homescreen) of blackberry and the menuentry in the phone app is missing. Why the application is not deployed as a background on the real dev app. ?

The only difference between the Simulator and real device is the language chosen, but I don't think it's important.

The application consists of files, as shown below.

import net.rim.blackberry.api.menuitem.ApplicationMenuItemRepository;import net.rim.device.api.system.Application;

public class Asterisk extends Application {   public static void main(String[] args)    {            // Create a new instance of the application            // and start it's event thread.            new Asterisk().enterEventDispatcher();    }

    public Asterisk()    {        //create a new instance of the menuitem       AsteriskMenuItem asterisMenuItem = new AsteriskMenuItem(40);

      //get the instance of the standard-menu an ad the new menuitem        ApplicationMenuItemRepository     .getInstance().addMenuItem        (ApplicationMenuItemRepository.MENUITEM_PHONE,asterisMenuItem);

    }}
package com.schiffl.mobile.asteris;

import net.rim.blackberry.api.invoke.Invoke;import net.rim.blackberry.api.invoke.PhoneArguments;import net.rim.blackberry.api.mail.Message;import net.rim.blackberry.api.menuitem.ApplicationMenuItem;import net.rim.blackberry.api.phone.Phone;import net.rim.blackberry.api.phone.PhoneCall;import net.rim.blackberry.api.phone.PhoneListener;import net.rim.device.api.system.ControlledAccessException;import net.rim.device.api.ui.Field;import net.rim.device.api.ui.UiApplication;

public class AsteriskMenuItem  extends ApplicationMenuItem{     //number to be dialed via Asterisk        String servicenumber  = "1234567";

      //using the default constructors here.        AsteriskMenuItem(int order)       {         super(order);     }

       //methods we must implement       //Run is called when the menuItem is invoked      public Object run(Object context)     {             /*             * Normally the dialed number could be found in the context object             * because of a bug in the api which is solved in v.4.7 the context            * object is always null for MENUITEM_PHONE so it is necessary to          * use a workaround, here the number is extracted from the field with focus,           * which contains the dialed number           */            Field myField = UiApplication.getUiApplication().getActiveScreen().getFieldWithFocus();           String phoneNumber = myField.toString();

          //TODO Convert phoneNumber to dtmf-tones

          try           {             PhoneArguments call = new PhoneArguments(PhoneArguments.ARG_CALL,servicenumber);              Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, call);

//                PhoneCall myCall = Phone.getActiveCall();//               myCall.sendDTMFTones(phoneNumber);            }         /*             * The ControlledAccessException is thrown             * if the system administrator restricts access to the phone application           * using application control.          */           catch (ControlledAccessException e)           {             //TODO some exceptionhandling             }

         //normally you can do something with the given context inside of the run-method           //because of a bug in the API the context is always null so, we don't use it...           return context;       }

       //toString should return the string we want to        //use as the lable of the menuItem        public String toString(){         return "Call via Asterisk";       }

}

The entry for the RRT signature was missing in my .csl file. I change it manually, I added

'52525400 = RIM API execution' requested signatures, deployed and it works...

Tags: BlackBerry Developers

Similar Questions

  • A simulator to simulate efficiently all limitations of a real device?

    I brought an IPhone app to BlackBerry and it works great on the Simulator.  One of IPHONE developers theother said day "wait until you get your application on the actual device. That's when the pain begins"and he stopped dead in my tracks. The big question is, it works perfectly in the real device too. Is the Simulator has the processor, memory, and any other restrictions of a real device?

    PS. can't afford a real device, so stuck with the blessed simulators.

    See you soon.

    Not sure that I count as a guru, but happy to offer my thoughts.

    Basically, I agree with the previous answers, you've had.

    Not sure if anyone has mentioned code signing and prompts security/permissions variety you can get on a real device.  I would recommend that you get the key signing, even if you need and sign your code for $20.  There is a good video on security prompts that I recommend that see you, too.  And business users would never be able to run your application due to the security provisions in the company.

    Relating to the performance, don't forget that the Simulator is faster than the device.  Much faster.  The one that annoys me is the time it takes for a page in the browser.  I have not done much image manipulation, but I think that the same thing happens with her.

    Concerning the aspect, the storm must be the biggest difference.  Remember that you are using a mouse on the simulator that is easy to point.  The simulator of life-size scale and then try to put your fingers on the screen to see if your fields are in fact quite large.  And you will find the keys on the real QWERTY devices a little different and surprisingly, different between different models.

    Get cod on the device takes a little thought.

    If a few other things, but the guys have already hit on the most important.

  • Problem test on a real device - app does not start

    I use

    Eclipse 3.5 Galileo

    BlackBerry JDE 5.0

    BlackBerry Desktop Software 6.0.0.43

    a real device Curve 8900 with the software updated to 5.0.0.681.

    I read that Simulators have problems with Blackberry Maps. So, I wanted to test my application on the actual device to see if I've run into the same errors. Packaging and code-signing everything has worked well. I then installed the software on the device through Blackberry Desktop software. I found the icon in the downloads folder of the device but you cannot start the application. When I click on it nothing happens. No no error message, nothing, simply no reaction. So I have no idea what went wrong. Does anyone have an idea or suggestion how know what's the problem?

    I can start and run the program on the Simulator.

    Hi navad.

    I had the same problem a few days ago.

    Only the developed app one shows no reaction. all other things are working well.

    to me, helped the following:

    When the Blackberry is running, remove the battery and wait 2 minutes.

    Replace the battery and the blackberry again.

    After that, you should be able to run your application.

    I hope this will help.

    CU

    Michael

  • More than two devices to connect to the LAN ports and none can see Internet

    If I connect another router to my Netgear and use this another router by connecting four or five devices, all can see the internet and work very well. But if I remove this another router and connect these four devices to one of the ports on my Netgear modem/router, these devices each receive its own IP address (as expected), but NONE of THEM can access the internet.

    No idea why?

    Everything works fine. Note, please, that the Netgear modem/router has always worked well - the problem was with the flaky DNS server addresses provided by Comcst.

  • How to develop and test the application mobile flex without the real device?

    I'm trying to read some information about it, but decided to ask also here.

    I have a project that has a company wants to grow me, it's for iPad. That's ok I am with Flex and the framework for web development, but not for mobile. Why? Because I have no idea how to test my application. I know generation ago it sort of the desktop version of the application with the change of the "back" button on the orientation stuff, but how do I know my application will look and work exactly the same (I mean NOT performance here). I mean you know how every android or iOS device have their native keyboard or native video player for example and I have only in the debug version of the application.

    The question is how to develop this application based on the desktop emulator or anything and then hope that my app looks and works on a device, as it should... Of course I can't afford to buy all the devices it is just to be able to test on it if necessary? So, how do you, how to test how my iPad app works on a device without a? I know I should get a licence from iOS dev to be able to package the app for iOS, but it's $ 99 per year or something like that I can handle, but how to test my application without having to buy the darn device? Are there any emulator for iPad or something like that I know what my customers will see when they get the application? One of my friends told me that the mac os x use the developers a tool - cause some kit of dev who has emulators for all iOS devices and you can build and test there immediately and that you can simulate virtually any combination of key for example, and he said he's working and seems to 1:1 as the real device but he didn't know if can I export an AIR application and try it like this, he only knew for app written in native code.

    If someone can just tell me how should I do this? Should I buy a mac os x computer laptop to test because I am a user of windows 7, or perhaps create a mac os x virtual machine and tests out there or maybe the only option is to actually buy the device... that would be terrible for a freelancer...

    I hope someone can save the day here! Thank you.

    F

    Since the AIR for iOS applications are compiled to ARM code you will not be able to run on iOS emulators running on Mac OSX.

    You can do a very simple test with the "Simulator" built into Flash Builder, but it is not much more than a window to AIR with a window size that matches the resolution of the selected iOS device.  When running in the simulator of the application is not compiled to ARM code so it will take a completely different code path than what will be the final release of iOS.

    Ultimately if you are developing for iOS with AIR nothing but for tests on real iOS devices.

  • BrowserFieldAPIDemo application does not work on the real device

    Hello

    anyone tried the demo of browserfieldapi running on a real device? When I try to run on the real device, it shows a white screen.

    Thank you


  • Council of softkey is not coming by clicking textfield on Simulator, it will show on real device

    I wore an android application for bb 10 app, here I am facing problems.
    1 key board is not coming by clicking textfield on Simulator, it will show on real device

    2. I want to show 6 pictures long in size on a page to display scrolling but memory is out of range

    Hello

    No. 1: If you started the Q10 Simulator, it is expected for the real device has a physical keyboard. The Simulator startup, select the Z10 and test again to get the virtual keyboard.

    2: this question would better fit for a new topic. In any case, a strategy would be to cut the long cards for the smaller pieces and loading them dynamically, effectively keep in mind a few.

  • Google addresses on real device

    Hi guys,.

    I have an application that uses the API of Google Places which is https connection. It works fine on the emulator when I put specific ssl and https settings in the .rimpublic file:

    [HTTPS HANDLER]
    application.handler.https.allowUntrustedServer = true
    [TLS HANDLER]
    application.handler.tls.allowUntrustedServer = true
    application.handler.tls.logging = true
    

    BUT, when I run on the real device, https fails. What should I do to make it work on my phone? Where should I change these settings? It is up to the carriers and the RIM servers, or I can do in the application?

    Hello

    Here is an article that talks about the HTTPS on BlackBerry connection.  I hope this helps.

    http://supportforums.BlackBerry.com/T5/Java-development/BlackBerry-support-for-HTTPS-connection/Ta-p...

    Thank you

    Naveen M

  • Impossible to debug on real device

    Hello

    When I try to debug an application on a real device debugging I get an error that a debug file is missing.

    After the tutorial on http://supportforums.blackberry.com/rim/attachments/rim/java_dev@tkb/18/1/How_to_Debug_and_Optimize _... he said that I may receive this error if "the reason why this might happen is that the version of the software on your device does not correspond to the.
    the software version of your Simulator

    I use blackberry curve withDevice software versio 5.0.0.103

    The research unit of the Simulator for OS 5.0.0 it does'nt seem to be a simulator for this version of the software.

    What can I do?

    You must launch the application manually on the device. I don't know why the breakpoints are not recognized. Try to delete the app, reboot the device, the app package, sing, load (debug as)... you can tell that the debugger is attached with success by the lines displayed in the Console view.

  • HttpPushDemo throws the error of missing on real device resource

    I am trying to run the example of httppushdemo on a real device to test for problems with an application to push.  However, if I run the application in the device, I get the error "Missing resource com.rim.samples.device.resource.HTTPPushDemoRes.

    I looked everywhere to find out how to get the resource on the device and impossible to find a solution.  The documentation I found would lead me to believe that it should be compiled in the Cod.

    Why I'm so confused (and frustrated after a long day of our push to debug problems)

    Thank you

    -Bill

    In older levels (4.3 and earlier OS), RIM ran the code, so that the resources (labels field, the names of menu etc.) where in a separate package.  It's a good way to demonstrate how you could internationalize applications, but also everyone confused because putting the application on the device, you need to charge upward of the cod resources as well.

    At the latest OS (4.5 +), they do not do this.

    The demo of http push has not changed, so you can take the source of the 4.5 or later in a previous level JDE and compile it.  It will take so NOT all external files of cod.  That's what I recommend you do.

    However, for you to win download the JDE together for a single file, it is here:

    /**
     * HTTPPushDemo.java
     *
     * Copyright © 1998-2008 Research In Motion Ltd.
     *
     * Note: For the sake of simplicity, this sample application may not leverage
     * resource bundles and resource strings.  However, it is STRONGLY recommended
     * that application developers make use of the localization features available
     * within the BlackBerry development platform to ensure a seamless application
     * experience across a variety of languages and geographies.  For more information
     * on localizing your application, please refer to the BlackBerry Java Development
     * Environment Development Guide associated with this release.
     */
    
    package com.rim.samples.device.httppushdemo;
    
    import java.io.*;
    import javax.microedition.io.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.util.*;
    import net.rim.device.api.io.http.*;
    
    /**
     * The client side of a simple HTTP Push system.
     * This application will listen for image data on the specified port and
     * render the data when it arrives.
     */
    public class HTTPPushDemo extends UiApplication
    {
        // Constants ----------------------------------------------------------------
        private static final String URL = "http://:100"; // PORT 100.
        private static final int CHUNK_SIZE = 256;
    
        // Members ------------------------------------------------------------------
        private ListeningThread _listeningThread;
        private HTTPPushDemoScreen _mainScreen;
        private RichTextField _infoField;
        private RichTextField _imageField;
    
        public static void main(String[] args)
        {
            HTTPPushDemo theApp = new HTTPPushDemo();
            theApp.enterEventDispatcher();
        }
    
        // Constructor --------------------------------------------------------------
        public HTTPPushDemo()
        {
            _mainScreen = new HTTPPushDemoScreen();
            _mainScreen.setTitle(new LabelField("HTTP Push Demo" , LabelField.USE_ALL_WIDTH));
    
            _infoField = new RichTextField();
            _mainScreen.add(_infoField);
    
            _mainScreen.add(new SeparatorField());
    
            _imageField = new RichTextField();
            _mainScreen.add(_imageField);
    
            // Spin off the listening thread.
            _listeningThread = new ListeningThread();
            _listeningThread.start();
    
            _infoField.setText("HTTP Listen object started");
    
            pushScreen(_mainScreen);
        }
    
        // Inner Classes ------------------------------------------------------------
        private class ListeningThread extends Thread
        {
            private boolean _stop = false;
            private StreamConnectionNotifier _notify;
    
            public synchronized void stop()
            {
                _stop = true;
                try
                {
                    // Close the connection so the thread will return.
                    _notify.close();
                }
                catch (IOException e)
                {
                    System.err.println(e.toString());
                }
                catch (NullPointerException e)
                {
                    // The notify object likely failed to open, due to an IOException.
                }
            }
    
            public void run()
            {
    
                StreamConnection stream = null;
                InputStream input = null;
                MDSPushInputStream pushInputStream=null;
    
                while (!_stop)
                {
                try
                    {
    
                        // Synchronize here so that we don't end up creating a connection that is never closed.
                        synchronized(this)
                        {
                            // Open the connection once (or re-open after an IOException),  so we don't end up
                            // in a race condition, where a push is lost if it comes in before the connection
                            // is open again. We open the url with a parameter that indicates that we should
                            // always use MDS when attempting to connect.
                            _notify = (StreamConnectionNotifier)Connector.open(URL + ";deviceside=false");
                        }
    
                        while (!_stop)
                        {
    
                            // NOTE: the following will block until data is received.
                            stream = _notify.acceptAndOpen();
    
                            try
                            {
                                input = stream.openInputStream();
                                pushInputStream= new MDSPushInputStream((HttpServerConnection)stream, input);
    
                                // Extract the data from the input stream.
    
                                DataBuffer db = new DataBuffer();
                                byte[] data = new byte[CHUNK_SIZE];
                                int chunk = 0;
    
                                while ( -1 != (chunk = input.read(data)) )
                                {
                                    db.write(data, 0, chunk);
                                }
    
                                updateMessage(data);
    
                                // This method is called to accept the push.
                                pushInputStream.accept();
    
                                input.close();
                                stream.close();
    
                                data = db.getArray();
    
                            }
                            catch (IOException e1)
                            {
                                // A problem occurred with the input stream , however, the original
                                // StreamConnectionNotifier is still valid.
                                System.err.println(e1.toString());
    
                                if ( input != null )
                                {
                                    try
                                    {
                                        input.close();
                                    }
                                    catch (IOException e2)
                                    {
                                    }
                                }
    
                                if ( stream != null )
                                {
                                    try
                                    {
                                        stream.close();
                                    }
                                    catch (IOException e2)
                                    {
                                    }
                                }
                            }
                        }
    
                        _notify.close();
                        _notify = null;   
    
                    }
                    catch (IOException ioe)
                    {
                        // Likely the stream was closed. Catches the exception thrown by
                        // _notify.acceptAndOpen() when this program exits.
    
                        if ( _notify != null )
                        {
                            try
                            {
                                _notify.close();
                                _notify = null;
                            }
                            catch ( IOException e )
                            {
                            }
                        }
                    }
                }
            }
        }
    
        private void updateMessage(final byte[] data)
        {
            Application.getApplication().invokeLater(new Runnable()
            {
                public void run()
                {
                    // Query the user to load the received message.
                    String[] choices = {"Ok" , "Cancel" };
    
                    if ( 0 != Dialog.ask("New message received. Do you want to render it?" , choices, 0) )
                    {
                        return;
                    }
    
                    _infoField.setText("Text received - size:  " + data.length);
    
                    try
                    {
                       _imageField.setText(new String(data));
                    }
                    catch (Exception e)
                    {
                        Dialog.inform(e.toString());
                        System.err.println(e.toString());
                    }
                }
            });
        }
    
        protected void onExit()
        {
            // Kill the listening thread.
            _listeningThread.stop();
    
            try
            {
                _listeningThread.join();
            }
            catch (InterruptedException e)
            {
                System.err.println(e.toString());
            }
    
        }
    
        private class HTTPPushDemoScreen extends MainScreen
        {
    
            /**
             * @see net.rim.device.api.ui.Screen#close()
             */
            public void close()
            {
                onExit();
    
                super.close();
            }
        }
    }
    
  • Impossible to install on a real device

    I have several applications in Eclipse and the plugin, I wrote.  They are all very well under the 8830 emulator work.

    If I generate an ALX file and try to install on my real blackberry using the desktop tool, it just says: "none of the additional applications not found" when I tried to load the ALX.

    I can't load the COD or JAR file either.

    What should I look for?

    I noticed that if the application is already installed, it (Office Manager) will not reinstall automatically unless you change the version of the new application to load, or you first uninstall the olderversion.

    try to uninstall a previous version of the application on the device (if this is the case)

  • Is it possible to intercept all start them console.log messages on real device using web Inspector?

    I'm trying to debug initiaization Stadium on a real device.  The problem is that I won't be able to establish a remote debugging session until the application is running.  And by then, I miss any message on the console that I have put in my initialization codes. Is there a technique to catch all console messages?

    In Web Inspector, you can also press CTRL + r to trigger a cooldown.

  • Unable to connect to my real device webservice (KSOAP)

    Hello friends of BB,

    I wrote an application for my black berry. My application to connect to a PHP Web service. I use the ksoap library to connect to my webservice. It works on my Simulator, but when I add my request on my real device does not connect to my webservice. I think I need to add something to my url. I call this URL:

    final String url = http://www.*****.de/webservice/dbservice.php
    
    final HttpTransport http = new HttpTransport(url);
    
    ...
    

    I hope someone can help me.

    greeting

    Dennis

    See the sticky thread here.

    http://supportforums.BlackBerry.com/T5/Java-development/connecting-your-BlackBerry-http-and-socket-c...

    As you can guess, this question has been answered repeatedly asked.

    In short, the Simulator emualtes a device connected to BES (if MDS - CS is running), it is not necessary for URL parameters in this environment.

    However, once you get on a real device that is not connected to BES, you will need to do a bit of work to determine what types of connectivity are available and develop your parameters of connection accordingly.

    A direct TCP connection (for example) will require "; deviceside = true' + settings specific to the network of the AFN.

    See this article:

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

  • Custom BrowserField appears in the real device Simulator only

    Hey guys, I got some piece of code that I can use to display HTML data stored in a variable. It worked fine in the Simulator, but when I tried to view it on a real device (I use 8900), it shows nothing.

    Here is the code (HTMLField.java): (I use the code here: http://supportforums.blackberry.com/t5/Java-Development/Display-HTML-in-a-Screen-Field/td-p/335074/p...)

    package app;
    
    import java.io.IOException;
    
    import javax.microedition.io.HttpConnection;
    
    import net.rim.device.api.browser.field.BrowserContent;
    import net.rim.device.api.browser.field.Event;
    import net.rim.device.api.browser.field.RedirectEvent;
    import net.rim.device.api.browser.field.RenderingApplication;
    import net.rim.device.api.browser.field.RenderingException;
    import net.rim.device.api.browser.field.RenderingOptions;
    import net.rim.device.api.browser.field.RenderingSession;
    import net.rim.device.api.browser.field.RequestedResource;
    import net.rim.device.api.system.Application;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.Status;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.io.http.HttpHeaders;
    
    /**
     * A field which displays HTML content.
     * @author Febiyan Rachman
     */
    public class HTMLField extends VerticalFieldManager implements RenderingApplication
    {
        private String data;
        private static final String REFERER = "referer";
        private RenderingSession renderingSession;
        private HttpConnection currentConnection;
        private Field field;
    
        /**
         * Default constructor
         * @param data
         */
        public HTMLField(String data)
        {
            this.data = data;
            renderingSession = RenderingSession.getNewInstance();
            // Enable JavaScript
            renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.JAVASCRIPT_ENABLED, true);
        }
    
        /**
         * Start parsing thread
         */
        public void parseHTML()
        {
            if(!data.startsWith("";
            HTMLFieldConnection thread = new HTMLFieldConnection(data, null, this);
            thread.start();
        }
    
        /**
         * Parse HTML
         * @param data
         */
        public void parseHTML(String data)
        {
            this.data = data;
            if(!data.startsWith("";
            HTMLFieldConnection thread = new HTMLFieldConnection(data, null, this);
            thread.start();
        }
    
        /**
         *
         * @param connection
         * @param event
         */
        public void processConnection(HttpConnection connection, Event event)
        {
            // Cancel previous request
            if (currentConnection != null) {
                try
                {
                    currentConnection.close();
                }
                catch (IOException e1) {
                }
            }
    
            // Set the current connection to the created connection
            currentConnection = connection;
    
            BrowserContent browserContent = null;
    
            try
            {
                browserContent = renderingSession.getBrowserContent(connection, this, event);
    
                if (browserContent != null)
                {
                    // Create a field which displays the HTML content
                    Field newField = browserContent.getDisplayableContent();
                    // Add field to this manager
                    if (newField != null)
                    {
                        if(field != null)
                        {
                            synchronized (UiApplication.getEventLock())
                            {
                                replace(field, newField);
                                field = null;
                                field = newField;
                            }
    
                        }
                        else
                        {
                            synchronized (UiApplication.getEventLock())
                            {
                                add(newField);
                                field = newField;
                            }
    
                        }
                    }
    
                    // Finish!
                    browserContent.finishLoading();
                }
            }
            catch (RenderingException renderingException)
            {
                System.out.println("RenderingException : " + renderingException);
            }
            catch (Exception exception)
            {
                System.out.println("Exception : " + exception);
                exception.printStackTrace();
            }
        }
    
        /**
         * @see net.rim.device.api.browser.field.RenderingApplication#eventOccurred(net.rim.device.api.browser.field.Event)
         */
        public Object eventOccurred(Event event)
        {
            int eventId = event.getUID();
    
            switch (eventId)
            {
                case Event.EVENT_URL_REQUESTED:
                {
                    HTMLFieldConnection thread = new HTMLFieldConnection(data, null, this);
                    thread.start();
                    break;
                }
                case Event.EVENT_BROWSER_CONTENT_CHANGED:
                {
                    break;
                }
                case Event.EVENT_REDIRECT:
                {
    
                    RedirectEvent e = (RedirectEvent) event;
                    String referrer = e.getSourceURL();
    
                    switch (e.getType())
                    {
                        case RedirectEvent.TYPE_SINGLE_FRAME_REDIRECT:
                            // Show redirect message
                            Application.getApplication().invokeAndWait(new Runnable()
                            {
                                public void run()
                                {
                                    Status.show("You are being redirected to a different page...");
                                }
                            });
    
                            break;
    
                        case RedirectEvent.TYPE_JAVASCRIPT:
                            break;
                        case RedirectEvent.TYPE_META:
                            // MSIE and Mozilla don't send a Referrer for META Refresh.
                            referrer = null;
                            break;
                        case RedirectEvent.TYPE_300_REDIRECT:
                            // MSIE, Mozilla, and Opera all send the original
                            // request's Referrer as the Referrer for the new
                            // request.
                            Object eventSource = e.getSource();
                            if (eventSource instanceof HttpConnection)
                            {
                                referrer = ((HttpConnection) eventSource).getRequestProperty(REFERER);
                            }
                            break;
                    }
    
                    HttpHeaders requestHeaders = new HttpHeaders();
                    requestHeaders.setProperty(REFERER, referrer);
                    HTMLFieldConnection thread = new HTMLFieldConnection(this.data, event, this);
                    thread.start();
                    break;
    
                }
                case Event.EVENT_CLOSE:
                    break;
    
                case Event.EVENT_SET_HEADER:        // No cache support
                case Event.EVENT_SET_HTTP_COOKIE:   // No cookie support
                case Event.EVENT_HISTORY:           // No history support
                case Event.EVENT_EXECUTING_SCRIPT:  // No progress bar is supported
                case Event.EVENT_FULL_WINDOW:       // No full window support
                case Event.EVENT_STOP:              // No stop loading support
                default:
            }
    
            return null;
        }
    
        public int getAvailableHeight(BrowserContent browserContent)
        {
            return 0;
        }
    
        public int getAvailableWidth(BrowserContent browserContent)
        {
            return 0;
        }
    
        public String getHTTPCookie(String url)
        {
            return null;
        }
    
        public int getHistoryPosition(BrowserContent browserContent)
        {
            return 0;
        }
    
        public HttpConnection getResource(RequestedResource resource, BrowserContent referrer)
        {
            return null;
        }
    
        public void invokeRunnable(Runnable runnable)
        {
        }
    
    }
    

    BrowserApp.java

    package app;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.EditField;
    import net.rim.device.api.ui.container.MainScreen;
    
    /**
     * @author Febiyan Rachman
     */
    public class BrowserApp extends UiApplication implements FieldChangeListener
    {
        HTMLField htmlField;
        EditField textField;
    
        public static void main(String[] args)
        {
            // TODO Auto-generated method stub
            BrowserApp app = new BrowserApp();
            app.enterEventDispatcher();
        }
    
        /**
         * Default constructor
         */
        public BrowserApp()
        {
            MainScreen screen = new MainScreen();
            screen.setTitle("Browser Test");
            htmlField = new HTMLField("");
            //screen.add();
            textField = new EditField("Tes : ", "");
            ButtonField button = new ButtonField("click", ButtonField.CONSUME_CLICK);
            button.setChangeListener(this);
            screen.add(textField);
            screen.add(htmlField);
            screen.add(button);
            pushScreen(screen);
        }
    
        // parseHTML and display it
        public void fieldChanged(Field field, int context)
        {
            // TODO Auto-generated method stub
            htmlField.parseHTML(textField.getText());
        }
    
    }
    

    HTMLFieldConnection.java

    package app;
    
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    
    import javax.microedition.io.HttpConnection;
    
    import net.rim.device.api.browser.field.Event;
    
    public class HTMLFieldConnection extends Thread implements HttpConnection
    {
        private long streamLength = 7000;
        private DataInputStream dataInput;
        private InputStream in;
        private String encoding = "text/html";
        private HTMLField htmlField;
        private Event event;
        private String data;
    
        /**
         * Default
         * @param data
         * @param event : event object for eventOccured() function
         * @param htmlField : HTML display field
         */
        public HTMLFieldConnection(String data, Event event, HTMLField htmlField)
        {
            this.data = data;
            this.htmlField = htmlField;
            this.event = event;
        }
    
        public String getURL()
        {
            return "";
        }
    
        public String getProtocol()
        {
            return "";
        }
    
        public String getHost()
        {
            return "";
        }
    
        public String getFile()
        {
            return "";
        }
    
        public String getRef()
        {
            return "";
        }
    
        public String getQuery()
        {
            return "";
        }
    
        public int getPort()
        {
            return 0;
        }
    
        public String getRequestMethod()
        {
            return "";
        }
    
        public void setRequestMethod(String s) throws IOException
        {
    
        }
    
        public String getRequestProperty(String s)
        {
            return "";
        }
    
        public void setRequestProperty(String s, String s1) throws IOException
        {
    
        }
    
        public int getResponseCode() throws IOException
        {
            return 200;
        }
    
        public String getResponseMessage() throws IOException
        {
            return "";
        }
    
        public long getExpiration() throws IOException
        {
            return 0;
        }
    
        public long getDate() throws IOException
        {
            return 0;
        }
    
        public long getLastModified() throws IOException
        {
            return 0;
        }
    
        public String getHeaderField(String s) throws IOException
        {
            return "";
        }
    
        public int getHeaderFieldInt(String s, int i) throws IOException
        {
            return 0;
        }
    
        public long getHeaderFieldDate(String s, long l) throws IOException
        {
            return 0;
        }
    
        public String getHeaderField(int i) throws IOException
        {
            return "";
        }
    
        public String getHeaderFieldKey(int i) throws IOException
        {
            return "";
        }
    
        public String getType()
        {
            return "text/html";
        }
    
        public String getEncoding()
        {
            return encoding;
        }
    
        public long getLength()
        {
            return streamLength;
        }
    
        public InputStream openInputStream() throws IOException
        {
            return in;
        }
    
        public DataInputStream openDataInputStream() throws IOException
        {
            return dataInput;
        }
    
        public void close() throws IOException
        {
    
        }
    
        public OutputStream openOutputStream() throws IOException
        {
            return new ByteArrayOutputStream();
        }
    
        public DataOutputStream openDataOutputStream() throws IOException
        {
            return new DataOutputStream(new ByteArrayOutputStream());
        }
    
        public void run()
        {
             try
             {
                 in = new ByteArrayInputStream(data.getBytes("UTF-8"));
                 dataInput = new DataInputStream(in);
             }
             catch (Exception e)
             {
                 System.out.println("HttpConnectionImpl : Exception : " + e);
             }
            this.htmlField.processConnection(this, this.event);
        }
    }
    

    Is there something wrong with it?

    Yes, as I finally tried again and again, it seems that the OS 5 does not support old stuff like that, it has its own browserfield2.

  • Detection of real device vs. Simulator

    is there a way to detect if the application is running on a real device or a simulator.

    Thank you.

    DeviceInfo.isSimulator)

Maybe you are looking for