Blackberry splash screen delay before appears - blackberry

I need to display a splash screen when I app instantiate, I wrote a class for splashScreen based on blackberry develpers knowlwdebase (link).
And its invoked from my following class.My problem is the splashscreen appears only after a deley,How can I solve it,If any one have idea Please help me,Thanks
class Test extends MainScreen{
Test(){
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run() {
UiApplication app=(UiApplication)getApplication();
Bitmap image = Bitmap.getBitmapResource("splah.png");
ListView listView = new ListView();
new SplashScreen(app, listView );
}
}

Try synchronized (UiApplication.getEventLock()). It is faster than invokeLater.
Test(){
synchronized (UiApplication.getEventLock()) {
UiApplication app=(UiApplication)getApplication();
Bitmap image = Bitmap.getBitmapResource("splah.png");
ListView listView = new ListView();
new SplashScreen(app, listView );
}
}

Related

Blackberry splash screen wait issue

I'm trying to launch a splash screen for a few seconds and then close it and launch the second screen.
For some reason, the code executes the "sleep" before showing the splash page and the splash page appears only for a fraction of a second and the second screen appears immediately. In other words when I click on the app icon, it waits for 2 seconds, then shows and immediately hides splash and jumps to HomeScreen.
I've tried many different combinations including invokeAndWait(), call backs and threads inside the Splash class but to no avail.
I've gone through many posts on SO as well.
Please note that I do not want the splash page to open the next screen; the launcher of the splash page (AppStart) should launch the next screen.
Please suggest a solution.
Code:
public class AppStart extends UiApplication
{
public static void main(String[] args) {
AppStart app = new AppStart();
app.enterEventDispatcher();
}
public AppStart() {
final Splash splashscreen = new Splash();
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication().pushScreen(splashscreen);
}
});
Thread waitthread = new Thread()
{
public void run()
{
try {
sleep(2000);
} catch (InterruptedException e) {
}
finally
{
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication().popScreen(splashscreen);
}
});
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication().pushScreen(new HomeScreen());
}
});
}
}
};
waitthread.run();
}
}
Splash
public class Splash extends MainScreen {
public Splash()
{
Bitmap bgImg = Bitmap.getBitmapResource("480x320-SplashScreen.png");
Background bg = BackgroundFactory.createBitmapBackground(bgImg);
getMainManager().setBackground(bg);
}
}
waitthread.run();
That is the problem. You are not starting a new thread, but hogging the main thread instead by callyng a method that sleeps it. Replace that line with this one:
waitthread.start();
And it should work.

BrowserField not showing the website.

This is the code i m running in my blackberry bold 9900 simulator but the BrowserField just shows the blank white screen and nothing. Is there any problem with my simulator or some setting needs to be done in it. Thanks in advance for help.
public class StartUp extends UiApplication
{
public static void main(String[])
{
StartUp start=new StartUp();
start.enterEventDispatcher();
}
public StartUp()
{
MainScreen screen = new MainScreen();
BrowserField browserField = new BrowserField();;
screen.add(browserField);
pushScreen(screen);
browserField.requestContent("http://www.google.com/news");
}
}
Verify if you have a network connection in your simulator, see this development guide article.

PopupScreen not show after pushing

I push the pop screen using following code, what pop screen not displays.
Please tell me what I missed.?
LabelField statusMsg = new LabelField("Hello");
PopupScreen statusScreen = new PopupScreen((fieldHFM));
UiApplication app = UiApplication.getUiApplication();
app.pushScreen(statusScreen);
Try
to do in following way
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication().pushScreen(statusScreen);
}
});

How can I use A dialog with No BUTTON and automatically Closes? On BlackBerry

I need to use a dialog. That appears 2-3 seconds and after closes automatically.
Which object should I use On BlackBerry?
you can also use
Status.show(String message)
Shows a status screen for two seconds.
or
Status.show(String message, Bitmap bitmap, int time)
Shows a status screen with specified
icon, for specified time.
Create a class that extends PopupScreen and use a TimerTask to automatically close it. So you would have code in your constructor that looks sort of like this:
Timer timer = new Timer();
timer.schedule(new TimerTask(){
public void run()
{
if(TestScreen.this.isDisplayed())
{
synchronized (Application.getEventLock())
{
TestScreen.this.close();
}
}
}
}, WAIT_TIME_IN_MILLISECONDS);

Navigate one screen to another screen based on time period in BlackBerry app

For my Blackberry application I am using a start up screen with progress bar. I am filling the progress bar using a timer and after the progress bar is complete, I need to navigate to another screen.
I am checking like this, where 'i' is time, increasing from 0 to 100.
timer.cancel();
if(i>=99)
UiApplication.getUiApplication().pushScreen(new TipCalculatorScreen());
This code is not working.
For progress bar I am using code like this:
private GaugeField percentGauge;
percentGauge = new GaugeField(null, 0, 100,50, GaugeField.PERCENT);
timer=new Timer();
timer.scheduleAtFixedRate(new TimerTask(){
int i=0;
public void run() {
percentGauge.setValue(i);
i++;
if(i>=99)
{
timer.cancel();
//for page navigating i am given like this here screen is not navigating getting error
UiApplication.getUiApplication().pushScreen(new nextscreen());
}
}
}, 100,100);
You need to make changes to the UI on the UI thread. The TimerTask is executing on its own thread. Instead of
UiApplication.getUiApplication().pushScreen(new nextscreen());
you should use
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
UiApplication.getUiApplication()..pushScreen(new nextscreen());
}
});
The update to your gauge control probably needs the same treatment.

Resources