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
Super Contributor
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

getting exception while pushing my own pop up screen in push notification

hi, i have implement push notification.., the code is working fine i'm recieving push notification and i have created my own pop screen for displaying the push mesg,,,, but i'm getting following exception while pushing the pop up screen  .
Untitled.png

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: getting exception while pushing my own pop up screen in push notification

NullPointerException is almost always an problem in your program.

 

Trace back through the stack trace, and when you get to your program, make sure that the variables you expect to be set are not null.

 

One common problem with background processing like is are static variables.  Remember that static variables are not Singletons, there is a separate static variable per Application. 

Super Contributor
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: getting exception while pushing my own pop up screen in push notification

actually peter..,hi have used this link to push notification http://rincethomas.blogspot.in/2012/07/push-notification-in-blackberry.html
look at the push message reader class - where i'm getting the msg in dilaog box ..

 Application.getApplication().invokeAndWait(new Runnable() {
                                public void run() {
                                    NotificationsManager.triggerImmediateEvent(0x749cb23a76c66e2dL, 0, null, null);
                                    ui.pushGlobalScreen(screen, 0, UiEngine.GLOBAL_QUEUE);
                                    
                                }
                            });

 and instead of showing in default dialog , i have created my pop up screen ..,to show the msg but that was giving me error , as i posted in my ist post, here is my code in PushMessageReader class, plz guide me

Application.getApplication().invokeAndWait(new Runnable() {
				    			
				            	public void run() {
				            		
				    				//NotificationsManager.triggerImmediateEvent(0x749cb23a76c66e2dL, 0, null, null);
                                                         ShowPushNotification shownotification = new ShowPushNotification();;
				            		final UiEngine ui = Ui.getUiEngine();
				    				ui.pushGlobalScreen(new ShowPushNotification(), 0, UiEngine.GLOBAL_QUEUE);
				    				
				    			}
				    		});

class ShowPushNotification extends PopupScreen{
		
		LabelField mesglabel = new LabelField();
		ButtonField okbtn = new ButtonField("Ok", ButtonField.USE_ALL_WIDTH | DrawStyle.HCENTER);
		
		public ShowPushNotification(){
			super(new VerticalFieldManager(), Screen.DEFAULT_CLOSE);  
			System.out.println("ShowPushNotification===================");
			//this.setBackground(BackgroundFactory.createSolidTransparentBackground(Color.WHITE, 80));
			
			 setBorder(BorderFactory.createSimpleBorder(new XYEdges(),Border.STYLE_TRANSPARENT));
			
			LabelField lbl = new LabelField("SUNRAYS", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER){
				 protected void paintBackground(net.rim.device.api.ui.Graphics g)
			        {
			            g.clear();
			            g.getColor();
			            g.setColor(Color.WHITESMOKE);
			            g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
			            g.setColor(Color.BLACK);          
			            
			        }
				
			};
	
			this.add(lbl);
			this.add(mesglabel);

			mesglabel.setText(text);
			//UiApplication.getUiApplication().popScreen(screen);
			okbtn.setChangeListener(new FieldChangeListener() {
				
				public void fieldChanged(Field field, int context) {
					// TODO Auto-generated method stub
					close();
				}
			});
  
		}

	}

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: getting exception while pushing my own pop up screen in push notification

Your stack trace shows there is a problem in pushing your Global Screen.

 

So the first thing you should do is try the same screen in a simple test program and make sure it does not suffer the same fate. 

 

I would create a simple test program, add a Button to it, and when you press this Button,have the processing push  a "new ShowPushNotification()".  If that works, try it as a Global screen, i.e. invoke using the UiEngline logic you are currently using. 

 

If it fails in a similar way, then you have a problem with the Screen, so change it until it works. 

Super Contributor
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: getting exception while pushing my own pop up screen in push notification

@peter, hi
               i have implemented what you said in your previous post to open the pop up screen with the same logic of uiengine on butto click.., i have done that and my screen is opening..,here is my code 

public final class MyScreen extends MainScreen
{
    ButtonField btn;
    Popupscreen popup;
    
    public MyScreen()
    {        
        // Set the displayed title of the screen       
        setTitle("MyTitle");
    
        popup = new Popupscreen();
        
        btn = new ButtonField("click me",ButtonField.CONSUME_CLICK);
        
        btn.setChangeListener(new FieldChangeListener() {
			
			public void fieldChanged(Field field, int context) {
				// TODO Auto-generated method stub
			
				try {
					final UiEngine ui = Ui.getUiEngine();
					
					Application.getApplication().invokeAndWait(new Runnable() {
						public void run() {
							//NotificationsManager.triggerImmediateEvent(0x749cb23a76c66e2dL, 0, null, null);
							
							ui.pushGlobalScreen(popup, 0, UiEngine.GLOBAL_QUEUE);
							
						}
					});
				} catch (Exception e) {
					// TODO Auto-generated catch block
					System.out.println(e.toString());				
					
				}
			}
		});
        add(btn);
    
    }
    
    class Popupscreen extends PopupScreen{
    	
    	LabelField label = new LabelField("A class extending the MainScreen class, which provides default standar behavior for BlackBerry GUI applications.");
    	
    	ButtonField Okbutn;
    	
    	public Popupscreen(){
    		super(new VerticalFieldManager(), Screen.DEFAULT_CLOSE); 
    		
    		Okbutn = new ButtonField("ok",ButtonField.FIELD_HCENTER);
    		
    		LabelField lbl = new LabelField("SUNRAYS", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER){
				 protected void paintBackground(net.rim.device.api.ui.Graphics g)
			        {
			            g.clear();
			            g.getColor();
			            //g.setColor(Color.WHITESMOKE);
			            //g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
			            g.setColor(Color.WHITESMOKE);               
			        }
			 };
		    
		     
			 add(lbl);
			 add(label); 
			 add(Okbutn); 
			 
			 Okbutn.setChangeListener(new FieldChangeListener() {
				
				public void fieldChanged(Field field, int context) {
					// TODO Auto-generated method stub

					close();
				}
			});
			 //this.setBackground(BackgroundFactory.createSolidTransparentBackground(Color.WHITE, 80));
		
			// setBorder(BorderFactory.createSimpleBorder(new XYEdges(),Border.STYLE_TRANSPARENT));	
    
    	}

    }

}

 but when i implement that one with my push notification as i told you in my previous posts.., my app is crashing
i don't why and where is the problem..,but i'm concern about one thing that in my push notification i have alternative point for recieving msg in background as you can check in the link i have given you.., i think that will cause the app to be crahed.. plz guide me

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: getting exception while pushing my own pop up screen in push notification

Apologies, I don't have time atm to go through that many lines of someone else's code right now. 

 

Have you tried contacting the original developer? 

 

I am wondering what failure you are getting now?  Also did you find in your testing that you were getting NullPointerExceptions?  Did you resolve these?

 

Sorry I can't help more.

Super Contributor
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: getting exception while pushing my own pop up screen in push notification

yes i solve the nullpointer 

Super Contributor
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd

Re: getting exception while pushing my own pop up screen in push notification

[ Edited ]

@peter, hi
              i have contaced the developer.. and he told me to bring the app in forground and then he told me to push the pop up screen with msg

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: getting exception while pushing my own pop up screen in push notification

In which case you will not be using a global screen.  But bringing your applicatin to the foreground is tricky - you will need to use a global event ot start some processing in your actual UiApplication.