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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Trusted Contributor
Posts: 182
Registered: ‎09-22-2011
My Device: 9700
My Carrier: airtel

How to reload a screen while coming back from a browser

I have a screen frome there i need to launch browser.Its fine upto now.But when i come back from from browser to that screen i need it to reload and shw some extra button.How to achieve it.

Contributor
Posts: 22
Registered: ‎11-09-2011
My Device: 9780Bold
My Carrier: DOCOMO

Re: How to reload a screen while coming back from a browser

[ Edited ]

Hi Use small logic that when you request browser to open with specified Url, before open just update your screen later you just enter into your browser sdcreen. when ever you come back from Browser your new updated screen will apear 

 

public class SampleScreen extends MainScreen implements FieldChangeListener
{

    VerticalFieldManager _vfm;
    ButtonField btn,new_btn=null;
    public SampleScreen()
    {
    	_vfm=new VerticalFieldManager(){
    		protected void sublayout(int maxWidth, int maxHeight) {
    			super.sublayout(Display.getWidth(),Display.getHeight());
    			setExtent(Display.getWidth(),Display.getHeight());
    		}
    	};
    	btn=new ButtonField("Open Browser");
    	btn.setChangeListener(this);
    	_vfm.add(btn);
    	add(_vfm);

    }
	public void fieldChanged(Field field, int context) {
		if(field==btn){
			/*you can write same logic here also
			if(new_btn==null){
				new_btn=new ButtonField("New Button");
				new_btn.setChangeListener(this);
				_vfm.add(new_btn);
				_vfm.invalidate();
			}
			*/
			BrowserSession session=Browser.getDefaultSession();
			session.displayPage("http://in.blackberry.com/");
		}
	}
	protected void onExposed() {
		if(new_btn==null){
			new_btn=new ButtonField("New Button");
			new_btn.setChangeListener(this);
			_vfm.add(new_btn);
			_vfm.invalidate();
		}
		super.onExposed();
	}
	public boolean onMenu(int instance) {
		//avoid  default menu
		return true;
	}
}

 

 

 

thanks

Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How to reload a screen while coming back from a browser

Hi,

Write onExposed() method in your screen and write reload code in that method when ever your screen is came back to browser that method will executed...

 

Regards,

Lakshman

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Developer
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: How to reload a screen while coming back from a browser

override onExposed and onUiEngineAttached to achieve this.

Developer
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: How to reload a screen while coming back from a browser

[ Edited ]

Try like this below code:

 

 LoadingScreen.java

 

public class LoadingScreen extends MainScreen implements FieldChangeListener
{
	
	VerticalFieldManager vertical;
	ButtonField click,show;
	public static boolean isBrowsing=false;
	public LoadingScreen() 
	{						
		createGUI();
	}

	private void createGUI() 
	{		
		vertical=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR|HORIZONTAL_SCROLL|HORIZONTAL_SCROLLBAR);		
		
		click=new ButtonField("Click To Browse");
		click.setChangeListener(this);
		vertical.add(click);
		
		if(isBrowsing)
		{
			show=new ButtonField("Show");
			show.setChangeListener(this);
			vertical.add(show);
		}
		
		add(vertical);
	}

	public void fieldChanged(Field field, int context)
	{
		if(field==click)
		{
			isBrowsing=true;//This is important; 	
			UiApplication.getUiApplication().pushScreen(new NewsBrowserScreen(this,"http://www.google.com/news/"));			
		}
	}
	
	public void refreshScreen()
	{
		deleteAll();
		createGUI();
		invalidate();
	}
	
	public boolean onMenu(int instance) 
	{
		return true;
	}
}

 

NewsBrowserScreen.java

 

public class NewsBrowserScreen extends MainScreen
{
	LoadingScreen loadingScreen;
	String url;
	VerticalFieldManager vertical;	
	BrowserField browserField;
	
	public NewsBrowserScreen(LoadingScreen loadingScreen,String url) 
	{
		this.loadingScreen=loadingScreen;
		this.url=url;
		createGUI();
	}
	private void createGUI() 	
	{	
		vertical=new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR|HORIZONTAL_SCROLL|HORIZONTAL_SCROLLBAR);			
		browserField=new BrowserField();		
		vertical.add(browserField);
		add(vertical);
		browserField.requestContent(url);
	}

	protected boolean onSavePrompt()
	{		
		return true;
	}
	
	public boolean onClose() 
	{
		if(LoadingScreen.isBrowsing)
		{
			loadingScreen.refreshScreen(); // This is important;
		}			
		return super.onClose();
	}	
}

 

I think you get the solution; 

 

 ===============================================================================

 

Feel Free to click LIKE button;

 



 

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
Trusted Contributor
Posts: 182
Registered: ‎09-22-2011
My Device: 9700
My Carrier: airtel

Re: How to reload a screen while coming back from a browser

protected void onUiEngineAttached(boolean attached) {
super.onUiEngineAttached(attached);
System.out.println("--------- screen A onUiEngineAttached method call" + attached);
if(attached){
Dialog.alert("clicked");

}
}

 

I am doing This.So when i go from one screen to this screen,the dialog is invoked.But after going to that screen if the launch the browser and come back to that screen,the dialog doesnt show up

Trusted Contributor
Posts: 182
Registered: ‎09-22-2011
My Device: 9700
My Carrier: airtel

Re: How to reload a screen while coming back from a browser

i cant use browserfield becuase my app should support from 4.,6

Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How to reload a screen while coming back from a browser

Hi,

 

Can u try to override onExposed() method insted of onUiEngineAttached(boolean attached)

 

Regards,

Lakshman.

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Trusted Contributor
Posts: 182
Registered: ‎09-22-2011
My Device: 9700
My Carrier: airtel

Re: How to reload a screen while coming back from a browser

protected void onExposed() {
Dialog.alert("clicked");
super.onExposed();
}

 

if i use this,then dialog is not invoked at all

Highlighted
Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How to reload a screen while coming back from a browser

Hi,

Can u check with break point if dialog only not invoked then place dialog in invoke later...

 

Regards,

Lakshman

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.