Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 81
Registered: ‎12-04-2012
My Device: BlackBerry@8520 smartphone(Edge,Wi-fi)
My Carrier: vodafone
Accepted Solution

Building My first App

Guys, I am new to the forum.I built a basic app which opens an Instant messaging menu-->System Messages.

However after giving a sleep of 1000ms the app switches to the MyScreen.java.However i Dont want My MyScreen to be visible.I want my IM Menu to stay on bb screen and then i want to navigate to menu-->options-->and to the screen that follows..Help me pzzz .And remember I am new to the community .Thanks:No:


package mypackage;

import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.ApplicationManagerException;
import net.rim.device.api.system.SystemListener;
import net.rim.device.api.ui.UiApplication;

/**
 * This class extends the UiApplication class, providing a
 * graphical user interface.
 */
public class MyApp extends UiApplication implements SystemListener 
{
    /**
     * Entry point for application
     * @param args Command line arguments (not used)
     */ 
    public static void main(String[] args)
    {
    	//BlackBerryMessenger bbm= BlackBerryMessenger.getInstance();

   try {
			ApplicationManager.getApplicationManager().launchApplication("net_rim_bb_qm_peer");
		 } 
   	 catch (ApplicationManagerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
   
   	 
   	 try {
			Thread.sleep(1000);
		 }
   	  catch (InterruptedException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

        // Create a new instance of the application and make the currently
        // running thread the application's event dispatch thread.
        MyApp theApp = new MyApp();       
        theApp.enterEventDispatcher();
    
        
   	 try
	 {
			Thread.sleep(1000);
	 }
	
   	 catch (InterruptedException e)
	 
	 {
			// TODO Auto-generated catch block
			e.printStackTrace();
	 }
   	
   }
   	 
   	 
    public MyApp()
    {        
        // Push a screen onto the UI stack for rendering.
        pushScreen(new MyScreen());
    }


	public void batteryGood() {
		// TODO Auto-generated method stub
		
	}


	public void batteryLow() {
		// TODO Auto-generated method stub
		
	}


	public void batteryStatusChange(int status) {
		// TODO Auto-generated method stub
		
	}


	public void powerOff() {
		// TODO Auto-generated method stub
		
	}


	public void powerUp() {
		// TODO Auto-generated method stub
		
	}    
}

 

Developer
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900
My Carrier: MTN

Re: Building My first App

What you are saying and what your code is doing is very different.

 

Your code is launching BBM and then you create a new instance of your app but in your app constructor, you're pushing a new "MyScreen"

 

With a little more detail, nevermind the code at the moment, what is it that you are trying to achieve?

Developer
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: Building My first App

i have used your code so change MyScreen.java

 

import net.rim.device.api.system.Application;
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.ApplicationManagerException;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.container.MainScreen;

/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class MyScreen extends MainScreen {
    /**
     * Creates a new MyScreen object
     */
    public MyScreen() {
        // Set the displayed title of the screen
        setTitle("MyTitle");
        addApplicationMenu(this);

    }

    /**
     * Adds a menu which allows the user to perform various message store
     * actions.
     *
     * @param mainScreen
     *            The screen to add the menu to
     */
    void addApplicationMenu(MainScreen mainScreen) {
        MenuItem appendUnreadMenuItem = new MenuItem("Open Messenger", 1, 1) {
            public void run() {
                try {
                    ApplicationManager.getApplicationManager()
                            .launchApplication("net_rim_bb_qm_peer");
                } catch (ApplicationManagerException e) {
                    e.printStackTrace();
                } finally {
                    Application.getApplication().requestBackground();
                }

            }
        };

        mainScreen.addMenuItem(appendUnreadMenuItem);

    }
}

 

and remove code from MyApp.java. your MyApp will be like this

 

**
 * This class extends the UiApplication class, providing a
 * graphical user interface.
 */
public class MyApp extends UiApplication
{
    /**
     * Entry point for application
     * @param args Command line arguments (not used)
     */
    public static void main(String[] args)
    {
        // Create a new instance of the application and make the currently
        // running thread the application's event dispatch thread.
        MyApp theApp = new MyApp();       
        theApp.enterEventDispatcher();
    }
    

    /**
     * Creates a new MyApp object
     */
    public MyApp()
    {        
        // Push a screen onto the UI stack for rendering.
        pushScreen(new MyScreen());
    }    
}

 

(or just copy pase code in your eclipse).

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Developer
Posts: 81
Registered: ‎12-04-2012
My Device: BlackBerry@8520 smartphone(Edge,Wi-fi)
My Carrier: vodafone

Re: Building My first App

Alright, ir seems that i was a bit confusing in my previous post, i would like to reframe.

what i want is an application which when run,

1)opens my im icon

2)opens BlackBerry Messenger

3)then opens the popup menu

4)Goes to options

5)opens a new screen wherein we can see a field "save chat history" -

6)I just want to play with its setting

 

I found another way of doing this if i come 2 know the MenuId.

However i m not able to do so.

P.s. my code just takes me to the "System Messages" and thats it .I dont know how to go further.

:Innocent: If u cud help....

Developer
Posts: 81
Registered: ‎12-04-2012
My Device: BlackBerry@8520 smartphone(Edge,Wi-fi)
My Carrier: vodafone

Re: Building My first App

hiii yes you solved a majority of my problem.....Thanks:Flowers:

But there is a minor itch I want to automate the whole thing

That is.............i dont want to manually navigate through the menu bar.

What i want is on running my applications the

"Save my messages: to Device/to card be automatically be checked.

Is That possible????

Thanks a billion times however

:Clap: