Request to close class (without GUI) app via the Menu - help please!

Hello everyone, as you can see I took the sample application for the execution of a background application and adds a system-wide menu. The question is how can I properly close the application via the menu.

I just moved from the C++ so mental conversion to Java is running (learn a lot of new ways to cause exceptions in a whole new language)

Any help would be appreciated, I've seen the question several times with no response or vague answers and no code to back it up.

Thank you!

/**
* GUILessApplication
*
* A sample application that appears on the Ribbon
* but has no user interface.
*/

package guiLessApp;

Net.rim.device.api.system import. *;
Import net.rim.blackberry.api.menuitem.ApplicationMenuItem;
Import net.rim.blackberry.api.menuitem.ApplicationMenuItemRepository;

/ public final class GUILessApp extends Application
{
public static BackGroundApp backGroundApp;
         
Public Shared Sub main (String [] args)
{
PAP GUILessApp = new GUILessApp();
theApp.enterEventDispatcher ();
}

public GUILessApp()
{
Creates and starts a new thread BackGroundApp.
          
backGroundApp = new BackGroundApp();
backGroundApp.start ();
                   
MyMenuItem myMenuitem = new MyMenuItem (17);

ApplicationMenuItemRepository
.getInstance (.addMenuItem)
(ApplicationMenuItemRepository
. MENUITEM_SYSTEM, myMenuitem);
}
    
The thread that is running in the background.
SerializableAttribute public class BackGroundApp extends Thread
{
Boolean stopThread = false;
public synchronized void stop()
{
stopThread = true;
}

public void run()
{
While (! stopThread)
{
You must run your treatment here.
This example prints just one line
in the output window BlackBerry JDE
System.out.println ("Application is running");

Sleep for 5 seconds to avoid the
application to run out of control
Try
{
Sleep (5000);
}
catch (System.Exception e)
{
Exception handling would be here.
}
}
}
}
Stop the thread to exit.
protected void onExit()
{
backGroundApp.stop ();
}
}

class MyMenuItem extends ApplicationMenuItem {}

using default constructors here.
MyMenuItem (order int) {}
Super (Order);
}

We must implement methods
Run is called when the menuItem is called
public Object execute (object context) {}

do something here

return the context;
}

toString must return the string that we want to
use as a marker of the menuItem
public String toString() {}
return "Close App";
}
}

Perfect!, just it sorted and it works like a charm.

Tags: BlackBerry Developers

Similar Questions

  • Creative cloud Office do not show App impossible to view and manage the app via the desktop, the wheel is idling

    Unable to view and manage the app via the desktop, the wheel is idling. Mac os 10.11.1

    Hello

    Please check the help below document:

    Does not open App | Wheels of progress turn continuously

    You can also view the nets below where this issue has been addressed:

    Adobe Creative Cloud / Desktop App / Home Screen: constant spinning wheel

    Creative Cloud Desktop App taped blue spinning wheel after update.

  • Send via the menu of the camera application

    I'm trying to implement a menu item in my application exactly like send it via the menu which is available after you have taken a picture. I tried to look at literature as citing a domestic demand but also to attach a file to send, but they do not really help us.

    Basically, I want to be able to send a jpeg file to my request as an attachment by email, BBM, twitter, etc..

    What is the best way to address the issue? I want the user to be able to modify the body of the message before sending it. Is it possible to have invokeApplication to allow me to do? Can I send the attachment as an argument somehow?

    Thanks in advance

    I was able to create a menu similar to that of the camera app with just a dialog box with the different shipping options.

    With respect to the fixing, I simplified my code, which worked:

    inputStream = getClass().getResourceAsStream("\test.jpg");
    
    byte[] data = IOUtilities.streamToBytes(inputStream);
    
    inputStream.close();
    
    Multipart multipart = new Multipart();
    
    SupportedAttachmentPart attach = new SupportedAttachmentPart(multipart, "image/jpeg", "test.jpg", data);
    multipart.addBodyPart(attach);
    TextBodyPart emailBody = new TextBodyPart(multipart, "This is the body message");
    multipart.addBodyPart(emailBody);
    Message m = new Message();
    m.setSubject("This is the subject");
    m.setContent(multipart);
    Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(m));
    

    That surround with try and catch MessagingException, IOException and NullPointerException statement. This works with 4.6, and as far as I know and with the file in the res folder of your project.

  • I reinstall xp on my toshiba laptop Dungeon wonders for SDBUS. SYS file that is not on the cd help please, I did once before without this problem

    I reinstall xp on my toshiba laptop Dungeon wonders for SDBUS. SYS file that is not on the cd help please, I did once before without this problem

    Please try to use different CD or simply remove the CD then insert again the installation request for the files.

  • I just changed my signature of account Windows Live Hotmail E-mail via the menu options, and since then, a big grey box appears on the emails that extends from left to right and is also important.

    Hello!

    A few weeks, I just change my signature to email hotmail via the menu options, and since then, a big grey box appears on the emails that extends from left to right and is also important. I went into the signing options, re-created the signature, and for 3 weeks completely removed the signature, but I always get the grey box display. Email being accessible via www.hotmail.com, and I don't have the problem, when I answer emails via my iPad2.

    Any help will be greatly appreciated, so that e-mail can be sent to the search normally. Thank you!

    Hi Paul,.

    The question you posted would be better suited to the Windows Live community. Please visit the link below to find a community that will provide the support you want.
    http://windowslivehelp.com/product.aspx?ProductID=2

  • BlackBerry smartphones how get torch home screen just show no apps when the menu bar is closed?

    Please bear with me, I'm struggling with how to explain cela ha ha!

    On the homescreen torch, you tap the 'all' downstairs bar to view the full menu. When you touch the bar once again it closes the application menu.

    When I got the torch the menu, when closed, displays only a row of 4 applications (SMS, browser, etc.) but I must have pressed something without knowing or changed a setting if it showed no apps at all, when I closed the menu. I preferred this as I love the home screen just show the background on the phone and not cluttered.

    However, it has changed back recently and is now showing TWO rows of apps now not even one! and cannot for the life of figure me out how to change it back?

    Thanks to all who help!

    Simply touch and drag down to the bottom of the screen. You will then see just the arrow ^ (you can change this way of 0 to 3 lines of icons). Then, when you tap on the bar with the arrow, you will get your full screen, the icons back.

  • What just happened to my Photos app? I need help please. :(

    A bit complicated, but totally mind boggling, and I need your help. This all started when I'm about to see my photos. I clicked on the Start menu, and then clicked on the Photos app. He just opened indeed, but all of a sudden it's just freezes and I can't seem to click pictures, and then it closes the force and brings back me to the start screen. Because I felt so mad and frustrated, I just came with the idea to uninstall this application and install it again from the store, and so I did. But when I was about to install the application again in the store, when I get the Photos app in the charm of the research, and I click the Photos app, I thought I'd install it with ease, unfortunately he only said 'you have this app' and we can't find the button "install". Just 2 questions: 1) I really own this app, but why the pictures tile app does not appear in the menu Start ; and 2) there are solutions to this problem of recover my Photos app/app tile and get back to work just the way that it used to be?

    For a better understanding on this issue, here is 2 pictures (or titles):
    This is the screenshot of store, in which is the time I try to re - install Photos app, but I can't because he said 'you have this app.
    And this is the screenshot of menu start without Photos app. He said that I have this app, but I can't find the Photosapp tile. Even if I search in all applications, I can't always find.
    If you answered, thank you very much, because I need this app.

    Hi BhoyKim

    You do not have the application, simply to reinstall this App do the following.

    1. open the store, right-click the main screen and select your applications on the top toolbar.

    2. you will see 2 drop-down menus in the top/left. Select applications from the first menu and sort by name from the second menu.

    3. Locate the Photos App and click on the application.

    4. on the bottom of the toolbar, click the install icon.

    It will be re - install this application.

    Let us know if it works for you.

    Concerning

  • Help. I have updated to iOS 9.2.1 and its killed my messages app and iMessages. Help, please

    I ignored the 9.2.1 iOS updated for ten days or so closing these annoying pop ups every day. But he updated with on me accepting it last night (how?-I swear to you that I never agreed to update)

    so now that I am on iOS 9.2.1 and when I open messages built in app it simply crashes constantly and does not open. Sometimes it freezes forever. Sometimes it crashes immediately. Sometimes, a variation of the two.

    one solution supposed to toggle the use of iMessages and off in settings. Then I disabled iMessages. Then when I tried to turn it back on imessage again, he asked for my Apple ID and password, I entered and press the sign in button. but then it just freezes when I press on sign in - and the application settings remains frozen indefinitely with the sign in iMessage window open.

    So I have now 2 numbers.

    1 jelly iMessage log in settings so I can't connect to use my e-mail address for iMessages. That is irrelevant at this time because:

    2. my built-in message application crashes and freezes and I can send receive view or do anything with the messages.

    just a update, I don't accept and did not want to do.

    Help, please

    Have you had a chance to restart your phone?

    Restart your iPhone, iPad or iPod touch - Apple Support

  • I can't download windows app store applications. Help, please!

    I'm unable to download apps from the store. When I try to install any application, I get an error that could not purchase completed. It happens that the two time if I install a free or paid app. And the error code is 0 x 80070422 please help!

    Thanks in advance.

    I recommend you to try the fix described in the following article to resolve your issue:
    Hope this helps, good luck :)
  • CS6 apps on the menu 'Open with' with OSX version CC

    Hello!

    Why the CS6 apps appear in the menu 'Open with' with CC OSX version? I have not installed? How to remove? Applications do not work...

    Screenshots:

    https://www.dropbox.com/s/mtsq9oow5j25vbu/screen%20Shot%202013-07-17%20at%2014.10.43.PNG

    https://www.dropbox.com/s/6gwrtlyn1vltelq/screen%20Shot%202013-07-17%20at%2014.10.24.PNG

    Thanks for the reply.

    Apps are not present anywhere in the system. Cleaning tool could not find them.

    But I've been sorted. I had carbon copy clone support my computer plugged USB hardrive. When I disassembled old applications gone too drive.

    Thanks for the help!

  • I upgraded yesterday so why the "close" tab is no longer in the menu file? How can I close a tab without leaving Firefox?

    the option 'close tab' is not on the drop down file today. That was before I updated yesterday to the new version of firefox. So, how can I do to close a tab?

    Just right click on the tab you want to close, and select close tab option.
    Otherwise, press Ctrl + W (or) Ctrl + F4 to close the active tab.

  • Share photos added to the photo library via the menu are not visible on the Photos

    Hello

    I started using DxO OpticsPro 10 to process Raw files. When I used the share menu in this application to "Add photo" pictures are exported but not visible in the Photos app. I see that they are in the photo library (Show Package Contents > Masters), but they are not visible in the Photos in the Photos app. However if I use "Export to Application" instead of "Add photo" in DxO OpticsPro the Photos app opens and the image is visible.

    You can't always do and changes directly to the photo library - you must use the program of Photos to import photos - adding photos to the library has no positive effect (and may even cause problems)

    LN

  • TypeError: Error #1115: 'class namel' is not a constructor.  Help, please!

    Hello

    This problem is going to be pretty hard to explain but here:

    I have a main class that is responsible for a table that contains 14 items of brewing.

    If a key is pressed 5 items are picked on this table and put it in another table so shufling again.

    Each 5 items are chosen at random and read a respective animation.

    After that, I have a new class that supports these 5 elements and shufles them by placing them in another table.

    A random element is levied on this table and then spliced, until nothing is left.

    What im will succeed to reach is that after this last picture lasts 0, I go back to the main class and addChild new button which when you click on

    Mediator 8 inspead of 5 elements.

    But whenever I try to add the code for the main class, I get this error:

    TypeError: Error #1115: 'class namel' is not a constructor.

    I know it's vague, but the classes are huge ova 1 k lines of code so it's difficult to see all the code.

    If you can help me rly sick appriciate that!

    THX pavel

    Test_Main.Btn1 is not on the display list of Test_Second - so the error.

    I'm not sure what you're trying to do, but it feels like you're under the impression that objects can be added to the class - not its instance - display list. It is not possible.

  • Export without red cross... Help, please...

    asas.png

    How to export without the red cross line? I am trying to export to AVI, but whenever I exported, it will be a red line between the movie. I am a newbie to AE.

    Thanks in advance...

    You are using a trial version of a plug-in. To remove the watermark (Red Cross), you will need a serial or registration number port. To understand that we're not only registered disable them one at a time until the watermark disappears.

  • a novice request that I have no sound on my laptopcan someone help please

    I can't find anything in the Panel to do it anymore - thanks

    For the display of concern, please provide as much detail as possible in your messages, please see the link below for more information.

    http://support.Microsoft.com/kb/555375

    To troubleshoot the sound for Windows XP, you can try using the link below.

    http://Windows.Microsoft.com/en-us/Windows/help/no-sound-in-Windows?T1=tab02

    In addition, if your copy of Windows XP came preinstalled on your computer, it is best that you contact the manufacturer of your computer as well as you will need perhaps to download and update your card drivers sound and mixers.

Maybe you are looking for