method object never called

Hey guys,.

I'm having a problem with the code below:

package mypackage;

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.Graphics;

public class MyApp extends UiApplication
{
    public static void main(String[] args)
    {
        MyApp theApp = new MyApp();
        theApp.enterEventDispatcher();
    }

    public MyApp()
    {
        pushScreen(new MyScreen());
    }
    public void paint(Graphics g) {
        g.setColor( Color.BLUE );
        g.fillRect(0, 0, 100, 100);

    }
}

Object the method is never called. I'm new to the BlackBerry development, but judging by my experience of Java, it should work. I don't see what the problem with this code.

Any help would be appreciated!

See you soon,.

Thomas

Your method object in the code below is simply a local method, since UiApplication does not implement object.

I think that you wanted to substitute her object in your screen class, but is not what you're doing here.

Tags: BlackBerry Developers

Similar Questions

  • Method is never triggered.

    I do some indepth BB10 development tutorials as I learn myself. Especially for beginners and for those coming to BB Android/Java Dev.

    In any case, I'm my current tutorial I want to talk about networking and FIO. So far I have not all errors in compiling or running the application however watch console I do not get an expected debug output.

    My code:

    Download.HPP (my class managed file download):

    #ifndef DOWNLOAD_HPP_
    #define DOWNLOAD_HPP_
    
    // Import required classes
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    // Class Download extends class QObject
    class Download:public QObject
    {
      // Macro code required for signals/slots mechanism
      Q_OBJECT
    
      // Methods and attributes are declared
      // in header files and implemented in cpp file.
      public:
        // Constructor takes our xml and same as in Java/Android we have
        // to provide Context class in this case in a form of QObject
        explicit Download(QUrl xml, QObject *parent = 0);
        virtual ~Download();
        // Method to return our downloaded data in array of bytes
        QByteArray downloadedData() const;
    
      // Signals and Slots implement similar mechanism in C++/Qt
      // as Observer/Observable concept does in Java/Android
      signals:
        void downloaded();
    
      // Method will emit a signal in a form of a downloaded() method
      // much like setChanged() and notifyObservers() does in Java/Android
      public slots:
        void fileDownloaded(QNetworkReply *reply);
    
      // An instance of QNAM class used for HTTP requests
      // much like DownloadTask in Android
      private:
        QNetworkAccessManager manager;
        QByteArray data;
    };
    
    #endif /* DOWNLOAD_HPP_ */
    

    The Download.cpp:

    #include "Download.hpp"
    
    // Notice unlike in Java/Android where we used a secondary thread
    // to process the download in the background all of our methods in
    // QNAM are async. so they are run in the background automatically.
    
    // The constructor of this class equals:
    // public Download(Url xml, Context context) {
    //   super(context);
    // }
    //  .. in Java/Android
    Download::Download(QUrl xml, QObject *parent):QObject(parent)
    {
      // Similar to addObserver(..) in Java/Android we need to link the
      // slot and signal from our Download calss. Here we use: connect()
    
      // Takes address to our QNAM variable
      connect(&manager, SIGNAL(finished(QNetworkReply*)), SLOT(fileDownloaded(QNetworkReply*)));
    
      // Our QNAM requires a Request in form of a QNetworkRequest
      // a lot like HttpUrlConnection
      QNetworkRequest request(xml);
    
      // Now we can use get method to retrieve our data
      manager.get(request);
    
      // 1. Create an instance of a Download class
      // 2. In turn this creates a request on a given URL
      // 3. QNAM Receives the request in a form of a QNRequest class
      // 4. QNAM Returns the response in a form of a QNReply class
      // 5. fileDownload() method is triggered upon compleated download
      // 6. fileDownload() emits a signal to observing classes
    }
    
    Download::~Download(){}
    
    // Think of the following method as onCompleatedDownload() from our
    // Listner class and our Observable
    void Download::fileDownloaded(QNetworkReply *reply)
    {
      // QNAM Returns the data it pulled from our URL in a form of QNReply
      // class we will store this data in a ByteArray
      data = reply->readAll();
    
      // Dispose of QNReply
      reply->deleteLater();
    
      // This is same as in our onCompleated..() method where we called
      // setChanged() and notifyObservers() methods to tell all classes
      // who are registered as listeners that our file has been downloaded
      emit downloaded();
    }
    
    // Simple getter method for received data
    QByteArray Download::downloadedData() const
    {
      return data;
    }
    

    And my applicationui.cpp

    #include "applicationui.hpp"
    
    #include 
    #include 
    #include 
    #include 
    
    // Import our download service class
    #include "Download.hpp"
    
    using namespace bb::cascades;
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
            QObject(app)
    {
        // prepare the localization
        m_pTranslator = new QTranslator(this);
        m_pLocaleHandler = new LocaleHandler(this);
    
        bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
        // This is only available in Debug builds
        Q_ASSERT(res);
        // Since the variable is not used in the app, this is added to avoid a
        // compiler warning
        Q_UNUSED(res);
    
        // initial load
        onSystemLanguageChanged();
    
        // Create scene document from main.qml asset, the parent is set
        // to ensure the document gets destroyed properly at shut down.
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // Create root object for the UI
        AbstractPane *root = qml->createRootObject();
    
        // Set created root object as the application scene
        app->setScene(root);
    
        // Prepare url for our resource
        QUrl url("http://news.google.com/?output=rss");
    
        // Once our main activity is set we can create a new
        // instance of Download class
        Download down(url, this);
    
        // Once Download(Observable) emmits a signal(notifyObserver)
        // in a form of downloaded() ApplicationUI which will be listening
        // will respond with showNotice()
        connect(&down, SIGNAL(downloaded()), SLOT(showNotice()));
    }
    
    // Shows message once Download class emmits a signal
    // that file download has been compleated
    void ApplicationUI::showNotice()
    {
      // Show notice in debug console
      qDebug("FILE DOWNLOAD COMPETE");
    }
    

    And applicationui.hpp

    class ApplicationUI : public QObject
    {
      Q_OBJECT
      public:
        ApplicationUI(bb::cascades::Application *app);
        virtual ~ApplicationUI() { }
    
      private slots:
        void onSystemLanguageChanged();
        // We will treat ApplicationUI as our Main Activity class
        // thus it will be observing our Download class. Once
        // we are notified that our download is complete we want to
        // do something with that data for now just display the message.
        void showNotice();
    

    In my applicationui.cpp in the constructor I create a new instance of download and request a download on successful download showNotice(); method must be triggered despite no error that the showNotice method is never executed because qDebug line is never displayed.

    To expand my question:

    Once a file is downloaded by programming where is the stored file and can we specify our own destenation or is the file stored under downloads folder automatically?

    You represent download like local and end of the function will be thus destroyed as well as the connection.

    Try to declare on the job not the battery. that is of new Download();

    Wherever you get your http response I think that it's already been destroyed.

  • Attachment Manager never called

    I need to open and analyze an attachment to the message. But I never have the opportunity to download an attachment.

    Installation program:

    -during the performance in the simulation using Eclipse 1.0 eJDE.

    -J' tried to run in the 4.7.0.46 and the 4.5.0.16 component packages

    -J' use the simulator of the ESS to send emails with attachments to the Simulator.

    -attachment file I tried names "Lists2.iif" and also "x-rimdevice - Lists2.iif.

    -the file is a simple text file, a little less than 10 KB in size.

    Comments:

    -l'email is always received with the attachment.

    -the menu, the option to open the attachment doesn't work or call my attachments Manager

    -None of the members of my call handler.

    Code:

    -J' tried to get this working using the ChapiDemo as a model so that the Attachment Manager old as described in the article DB-00475 Knowledge Base and I get the same result in both cases.

    -I am currently trying to get this to work with the Attachment Manager.

    I walked through my registration code that runs when the system starts successfully.

              // Register an attachment handler to read attachments of iif type.
              AttachmentHandlerManager ahm = AttachmentHandlerManager.getInstance();
              ahm.addAttachmentHandler(new IIFAttachmentHandler());
    

    The handler code is below and none of the methods called;

    public class IIFAttachmentHandler implements AttachmentHandler {
    
      /* (non-Javadoc)
       * @see net.rim.blackberry.api.mail.AttachmentHandler#menuString()
       */
      public String menuString() {
        return "Import attachment to FooBar App.";
      }
    
      /* (non-Javadoc)
       * @see net.rim.blackberry.api.mail.AttachmentHandler#run(net.rim.blackberry.api.mail.Message, net.rim.blackberry.api.mail.SupportedAttachmentPart)
       */
      public void run(Message arg0, SupportedAttachmentPart arg1) {
        byte [] rawData = (byte[]) arg1.getContent();
        IIFParser parser = new IIFParser (new String(rawData));
        parser.parse();
      }
    
      /* (non-Javadoc)
       * @see net.rim.blackberry.api.mail.AttachmentHandler#supports(java.lang.String)
       */
      public boolean supports(String arg0) {
        boolean rc = false;
        if ((arg0.length()-arg0.indexOf("iif")) == 3) {
          rc = true;
        }
        return rc;
      }
    
    }
    

    Issues related to the:

    1. it is even possible to get this working in simulation? If so, I'm missing a component any attachment downloader?

    2. given the code above suggestions on how to fix or debug code? As I say it's having saved ok, but never called.

    3. If I come back to try to get this to work using the approach of the JSR 175 ChapiDemo, would it even work for a defined application as CLDC or the app should be defined as a MOPED.

    Thanks in advance.

    I changed the file name of 'x-rimdevice' - Lists2.iif to "x - rimdeviceLists2.iif" and now my media method is called. It has a bug in the way if calculates press it, but it is a different matter.

    I have this will mark it as resolved, but if someone can always answer to question 3 to see if the application has a moped or not not to use Manager JSR175 of content, that would be greatly appreciated because my preference is to use this approach.

  • extend ListField, how to get a valid result of getSelectedIndex inside the method object?

    Hi all

    I have replace the method object to extend ListField to create my own color ListField.

    I need to avoid the double drawRow between the method object

    and the drawFocus() method.

    inside the method object, I always get the 'bad' selectedIndex (previous)

    (or rectangular previous on getFocusRect()).

    my questions are:

    1. how to get current selectedIndex (or FocusRect) inside the method object when we extend ListField?

    2. is there any other method called before object, the method which returns SelectedIndex valid?

    3. how to avoid the double drawing between object and drawFocus()?

    Thank you.

    If everything you do is add your own color, and then you can do this by using a fillRect in the drawListRow method.  In there.  I have the code that did this, but only for lines not targeted, as it detects with:

    If (listField.getSelectedIndex ()! = index) {}

    //

    }

  • PSSigValGetAPLabelProc callback is never called, why?

    I understand DigSig example and I'm going to convert it to a proper dig signature plugin. So far I got the creation of GIS to dig, the validation and the creation of GIS satisfactory appearance, but what I don't understand is why my registered PubSec (Acrobat 9 sdk example) both call of the plugin back are never called.

    They are: PSSigValGetAPLabelProc and PSGetLogoProc. In fact, I need to be able to update the n1 and n3 layers according to the validation of signature whenever a PDF file is opened. Documentation, I learned that the reminders above is where should I put my code.

    In SigCreateAPNXObj callback, there is a comment:

    You must have generated if you want your PSSigValGetAPLabelProc callback called n1 and n3

    From there, I figured I should at least specify n1 or n3. So I added the layer no. 1 in this method, as follows:

    xObjArray [0] = DigSigAPXObjectFromLogo (cosDoc, stmUnknownData, 0, stmUnknownBBox & bboxRec);

    but still PSSigValGetAPLabelProc is not called (I m debugging plugin btw). I checked that this call back is in record time as well.

    Well want to, help me.

    Therefore #5 is not an option - you'll need to have this deleted requirement given that you cannot accomplish.  I would also delete #6 as well as it's a BAD IDEA for many reasons.   All the others are fine.

  • DSHandler::GetLogo never called in DocSign

    Hi all

    I noticed a small problem with the plugin DocSign example comes from the 9.1 SDK: custom signature logos (respectively the green check, Red Cross and the yellow question mark) are never displayed and are instead replaced by... a yellow question mark. I have first if it was the question of the status of 'unknown' signature mark, but after investigation, it seems that the method DSHandler::GetLogo is, in fact, never called at all.

    As I change anything to the code source DocSign, and since then he has worked well with other users, I guess it must be some sort of bug in the current version of adobe acrobat.

    "Build" the plugin on Windows XP with VS9, and I tested it on Windows Vista with the trial versions of Adobe Acrobat Pro and Acrobat Pro Extended Adobe updated.

    Anyone know a work around?

    Thank you
    M.H.

    No, you can't wait for that.

  • What happens when ClearTask is never called?

    I use a NOR-6259 with the C API of Linux. What happens when a task program is interrupted and the ClearTask function is never called? Is it possible to query the driver for all running tasks, or better yet, is it possible I can assure that the device reset to a base state?

    In particular in the development, it is nice to be able to simply CTRL-C or something like that to kill a program bug.

    I don't think there is a good way to do it using our C API. If it was on a Windows machine, we have a program called MAX which will allow you to reset the device from there, but I don't think it is available on Linux. I think the only way is to reset the device.

  • Microsoft never call houses and tell them that their computer has problems?

    Original title: scams?

    Microsoft never call houses and tell them that their computer has problems?  Some guy called who I could barely understand and wanted to guide me through some things.  They said they got my # registration of Microsoft.

    Fake phone calls to technical support

    Such unsolicited telephone calls are almost always a common scam. Do not let them give any info, do not give access to your PC, not give them all the money and do not go to all the websites that they suggest. One moment.

    Please see:

    http://www.microsoft.com/en-gb/security/online-privacy/msname.aspx .

    Microsoft does ever not requested for telephone calls of support or security.

    (such persons may use names other than Microsoft as well)

  • Microsoft secuity never call a House to ask questions?

    Microsoft secuity never call a House to ask questions?

    Just got a call and they said that they were Microsoft Security, someone at - he never head of this?

    It's a scam.  Probably from 'phishing' or want to access your computer and/or who want to sell you something.  MS will not call you unless you called their request for assistance.

    http://www.Microsoft.com/security/online-privacy/msName.aspx

    http://www.Microsoft.com/security/online-privacy/phishing-scams.aspx

    http://www.Microsoft.com/security/online-privacy/avoid-phone-scams.aspx

    http://www.mypchealth.co.UK/GuideScam.php

    http://blogs.msdn.com/b/securitytipstalk/archive/2010/03/09/Don-t-fall-for-phony-phone-tech-support.aspx

    http://ask-Leo.com/i_got_a_call_from_microsoft_and_allowed_them_access_to_my_computer_what_do_i_do_now.html

  • I received a phone call telling me they wanted to fix my computer, but I've never called anyone. Is it a scam?

    Original title: annoying phone calls

    I RECEIVED A PHONE CALL TELLING ME THEY WANTED TO FIX MY COMPUTER

    BUT I'VE NEVER CALLED ANYONE. What is going on? IS THIS A SCAM TO GET INTO OUR FILES?

    I RECEIVED A PHONE CALL TELLING ME THEY WANTED TO FIX MY COMPUTER

    BUT I'VE NEVER CALLED ANYONE. What is going on? IS THIS A SCAM TO GET INTO OUR FILES?

    100% SCAM!

    Simply hang up.

    Read some of the many phone calls from phony support.

    http://answers.Microsoft.com/en-us/search/search?searchterm=phony+support+phone+calls&CurrentScope.ForumName=&CurrentScope.filter=&askingquestion=false

  • MenuItems run() method that is called from the thread eventdispatching?

    Hello

    is it? I know that MenuItem itself extends thread, but I wonder why this method is called run() and finally and above all it would'nt be worse if this method would be called from a Thread.

    THX

    In fact the menu items are run on the thread of the event. You can see this by creating a menu item long-term. The menu will not close and will not refresh the screen.

  • Error caused by the overrided method object build

    Hello world

    When I build my Active blackberry Setup, I get the error:

    I/O Error: Cannot run program "jar": CreateProcess error=2, The system cannot find the file specifiedrapc executed for the project MyApplication
    

    This happens when I have this code:

    LabelField lblTitle = new LabelField(title) {
        protected void paint(Graphics graphics) {
            graphics.setColor(0x00FFFFFF);
            graphics.clear();
            super.paint(graphics);
        }
    };
    LabelField lblSubTitle = new LabelField(releaseYear + ", " + rating) {
        protected void paint(Graphics graphics) {
            graphics.setColor(0x00FFFFFF);
            graphics.clear();
            super.paint(graphics);
        }
    };
    
    vfmHeader.add(lblTitle);
    vfmHeader.add(lblSubTitle);
    screen.add(vfmHeader);
    

    If I had to remove the method object overrided in the LabelField lblSubTitle, however, the build error does not. I tried to change a LabelField to a RichTextField lblSubTitle, and I still get the same error.

    Very strange. Anyone know why this is happening? Thank you!

    I found the solution to my problem here:

    http://www.BlackBerryForums.com/rim-software/79668-JDE-build-all-problem.html

    Basically, I removed all older versions of Java that I had and I installed this following:

    J2SDK-1_4_2_15-windows-i586 - p.exe (JDK 1.4.2 version 15)
    JDK-1_5_0_12-windows-i586 - p.exe (JDK 1.5.0 version 12)

    JDK 1.5.0 is necessary because otherwise the JDE Eclipse plug-in will not start with 1.4.2.

    Without having the JDK 1.6, however, the MDS - CS will organize not (within Eclipse). I had to manually download "BlackBerry email and MDS 4.14 Service simulators", start it and then run my application.

    I hope this can help someone down the line...

  • g.clear () call to the method object refuses the development of drawing for checkbox

    Hello

    I have this custom field extend the CheckboxField, with him object method is overloaded as follows:

    protected void paint (Graphics g)
    {
    int bgColor = _fontStyle.getBackgroundColor ();
    If (bgColor! = - 1).
    {
    g.setBackgroundColor (_fontStyle.getBackgroundColor ());
    g.Clear ();
    }
    g.setColor (_fontStyle.getForegroundColor ());
    Super.Paint (g);
    }

    the _fontSytle is defined by the user and transmitted as a reference of custom style, everything works fine in a first time without g.clear (), but I soon found out when the background color is black, while the foreground is white, paint reverse color. So I added this g.clear () and the problem was solved.

    However, the compensation seems to graphics here refuses the development of drawing and I was not able to trace which is cleaned and what is the indicator for the development of design. BTW, the "g.isDrawingStyleSet (Graphics.DRAWSTYLE_FOCUS)" returns true.

    So I was wondering if anyone here can provide a diagnosis on what could be the cause and how to fix it. Thanks in advance.

    Christian

    Nope, the g.clear () must be called to display the colors correctly. As I said, it can work in some cases, but just mess up from time to time.

    So what I do now is take a workaround to override the drawFocus() as default

    protected void drawFocus(Graphics g, boolean on)
        {
            refreshFooter(on ? getLabel() : "");
            // customize draw focus logic here as the default one conflicts with the paint method
            XYRect rec = new XYRect();
            getFocusRect(rec);
            g.invert(rec);
        }
    

    Thus the development of drawing must rely on paint and so don't mess the color.

    In any case, thanks much for the reply!

  • getLocation() method cannot be called from event thread

    Hello

    I use a thread that runs an executable object, which gets gps location. This thread is called in the constructor of the form. The first time, it works fine, but then I get the error getLocation.

    class GetGPSThread extends Thread
    {
    GPSRunnable _gpsObject;
         
    GetGPSThread()
    {
    _gpsObject = new GPSRunnable();
    }
         
    public void run()
    {
    _gpsObject.run ();
          
    While (! _gpsObject.isFinished ())
    {
    try {}
    Sleep (200);
    } catch (InterruptedException e) {}
    Generative TODO catch block
    e.printStackTrace ();
    }
    }
          
    Renew the screen
    If (_gpsObject.getLatitude ()! = 0 & _gpsObject.getLongitude ()! = 0)
    {
    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {
    public void run()
    {
    loadScreen (_gpsObject.getLatitude (), _gpsObject.getLongitude ());
    }
    });
    }
    on the other
    {
    UiApplication.getUiApplication () .invokeLater (new Runnable()
    {
    public void run()
    {
    Dialog.Alert ("your position not found");
    }
    });
            
    }
         
    }
         
    }

    "This thread is called in the constructor of the screen".

    We see this code in your constructor?.

    I guess you really want to say this thread is 'start '.  Don't forget that

    . Run()

    does not run a Thread, it executes the run() method in the Thread.  To start a separate Thread, you must use

    . Shart().

  • Microsoft never call their users? I just got a call from someone who said they were from Microsoft and he wanted me to run something.

    I just got a call from someone who said they were from Microsoft. It was obviously of the India. In any case, he said that there are problems with my computer and it asked me to do something, I would not.  He hung up. He told me to click the button of windows on my keyboard. Then he told me type something in and running. But I refused. I said, how end I call Microsoft and give them your name... HE HUNG UP.

    Hello DianeMcGettigan,

    It is simply one of the many scams that are doing the tour.

    Unless you have a prepaid support contract with Microsoft, then Microsoft will never contact you by phone, mail or e-mail about problems with your PC. You did while refusing to allow him access to your PC. All they want to do is to have access to your PC, so they can steal personal data (banking etc.) on your part.

    This forum post is my own opinion and does not necessarily reflect the opinion or the opinion of Microsoft, its employees or other MVPS.

    John Barnett MVP: Windows XP Expert associated with: Windows Expert - consumer: www.winuser.co.uk |  vistasupport.mvps.org | xphelpandsupport.mvps.org | www.silversurfer-Guide.com

Maybe you are looking for