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
Deepu_George_Jacob
Posts: 234
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

How to pass BBMPlatformContext reference to the main screen class??

Hai ,

 

        I am trying to pass BBMPlatformContext in UIapplication to the mainScreen class .. but it shows error  ("Null pointer exception"). anyone have solution for this problem .. please help me..

 

Thanks

Deepu George Jacob

Please use plain text.
Developer
Deepu_George_Jacob
Posts: 234
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to pass BBMPlatformContext reference to the main screen class??

This is my sample code 

 

public MyBBMPlatformApp()
{
myplugin = new MyBBMAppPlugin();






invokeLater(new Runnable()
{

public void run()
{
try
{
platformContext = BBMPlatformManager.register(myplugin);
}
catch(Exception e)
{

}

MyBBMPlatformContextListener platformContextListener;
platformContextListener = new MyBBMPlatformContextListener();
platformContext.setListener(platformContextListener);


}


});

pushScreen(new MyBBMPlatformScreen(platformContext));


}

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to pass BBMPlatformContext reference to the main screen class??

Look hard at your code and try to figure out the order in which things are processed.

 

When does the connection to the BBM get established?  When is the constructor for your Screen run?  What does invokeLater mean?

 

If this doesn't help, put System.out.println messages in and debug your app. 

 

I suggest that you initiate the BBM connection from your MainScreen.  So move the connection code to your MainScreen and then it will have access to the context.

 

Hope this makes sense?

Please use plain text.
Developer
Deepu_George_Jacob
Posts: 234
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to pass BBMPlatformContext reference to the main screen class??

I followed this documentation to implementing BBM please chek it..

 

http://docs.blackberry.com/en/developers/deliverables/25690/Register_your_app_with_the_BBM_Platform_...

 

Thanks

Deepu

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to pass BBMPlatformContext reference to the main screen class??

That code is correct, but it does not try to pass the context in to the Screen does it?

 

Like I said, think about how the various steps you have will be processed, I have given you some questions to help with this thought process.  If that doesn't do it, debug. 

 

As a clue, the instructions are NOT all processed in the order written. 

Please use plain text.
Developer
Deepu_George_Jacob
Posts: 234
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to pass BBMPlatformContext reference to the main screen class??

hai, 

       I am established connection within the mainscreen ... now its works fine....thankyou for you help peter

 

 

Deepu

Please use plain text.
Developer
Deepu_George_Jacob
Posts: 234
Registered: ‎12-13-2011
My Device: Curve 9380
My Carrier: Vodafone-IN

Re: How to pass BBMPlatformContext reference to the main screen class??

I cant register platform context outside the run method

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to pass BBMPlatformContext reference to the main screen class??

Glad you got the method working in the MainScreen.  More importantly, I hope you understand why the change made it work.  There is a lot of similar asynchronous processing involved in BBM. 

 

Not clear what your last post is all about.

 

Just to clarify, you should not attempt o establish a connection in other circumstances, for example you should not try to establish connection as part of the main90 or the Screens constructor.  The connect has to be run on an independent Thread with access to the UI.  . 

 

Can you explain the circumstances of your problem and why you are trying to establish this connection outside the run method?

Please use plain text.