Pop to home screen - blackberry

In my app I fave some screens one after another, and I need to pop to home screen any time. Is there any way to find out is active screen is the first one? Or, may be, there is any function to pop to root screen without cycle of poping to previous ones?
EDIT In different words, I need my app to go to previous screen on click on blackberry "back" button (it do this without any additional code), and go to the screen, user first see when starts this application on click on "Home" button from my user interface

This helps you any time and any where:
Write this method in startup class(StartUp.java):
public static void popupScreens()
{
int screenCount = UiApplication.getUiApplication().getScreenCount();//Gives how many screens are active state in background;
for (int i = 0; i < screenCount; i++)
{
Screen screen = UiApplication.getUiApplication().getActiveScreen();
UiApplication.getUiApplication().popScreen(screen);
}
}
and call this method at any place with class name(EX: StartUp.popupScreens) in any where then it popup all the screens in the stack.

First, you will need to organize your screens, application logic and clearly define what screens you want to be on the UI stack and those that don't. For those screens that don't need to be on UI stack, you can dismiss them automatically when another screen is pushed on top of it:
class SplashScreen extends FullScreen
{
protected void onObscured()
{
close();
}
}

Add menu to the Screen for having option Gotohomescreen some thing like this. Just pop the active screen from the display stack an push your home screen from the menus's run() method. For efficiently. If you want to go back in your application you can pop the active screen and it will go to that screen from where you have come.Let suppose you have added a backButton you can just override the fieldchanged method of the button and in fieldchanged method do something like this.
if(field == backbutton) {
UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
}
using the memory here is your answer
The screen at the top of the stack is the active screen that the BlackBerry device user sees. When a BlackBerry device application displays a screen, it pushes the screen to the top of the stack. When a BlackBerry device application closes a screen, it removes the screen off the top of the stack and displays the next screen on the stack, redrawing it as necessary. Each screen can appear only once in the display stack. The BlackBerry JVM throws a runtime exception if a Screen that the BlackBerry device application pushes to the stack already exists.
A BlackBerry device application must remove screens from the display stack when the BlackBerry device user finishes interacting with them so that the BlackBerry device application uses memory efficiently

Related

Can I make my iphone app use only a portion of the screen

I was hoping to create a small windowed screen when the home button is pressed. It would keep a portion of the app process open while another app isn't open.
So say I had music playing on the app and when the home button gets pressed the screen would be windowed or shrunk and just displayed over the main screen (kind of like the little help button that can be moved around). Would using widgets in IOS 8 work?
When the user presses the Home button, the app goes to background, and that's it. You can't customize that action.
You only get a notification that the user closed the app so that you can save your app state or data for the next launch.

Hide UI after resigning application [duplicate]

This question already has answers here:
Display a view or splash screen before applicationDidEnterBackground (to avoid active view screenshot)
(8 answers)
Closed 8 years ago.
The question is the following:
My app can be protected with a password. When the user presses home button, application resigns inactive. After reopening it, app shows "enter password" screen. But before it shows up, the initial content screen is visible for a moment. Also if, after pressing home button, user enters preview mode (home button double pressed), preview shows content screen, not password screen.
So here are two questions:
How can I change UI (to password screen or to some placeholder) before application gets resigned, so that in preview mode user would see something other than the content screen.
How can I make application NOT show content screen for a moment (before password screen) when application becomes active again.
Would be thankful for any help.
From the iOS App Programming Guide
What to Do When Moving to the Background
Apps can use their applicationDidEnterBackground: method to prepare
for moving to the background state. When moving to the background, all
apps should do the following:
Prepare to have their picture taken. When the
applicationDidEnterBackground: method returns, the system takes a
picture of your app’s user interface and uses the resulting image for
transition animations. If any views in your interface contain
sensitive information, you should hide or modify those views before
the applicationDidEnterBackground: method returns.
So, in your applicationDidEnterBackground method you should hide your main view and present your 'login' view.
Update After a bit more research, it turns out you can't present a view controller - you can only affect the root window. I have tested the solution in this answer - Display a view or splash screen before applicationDidEnterBackground (to avoid active view screenshot) and it works - So you can create an image that shows your login screen and put that over the top of your UI.

Popping multiple screens in a BlackBerry application

I writing a BlackBerry app which has multiple screens that the user navigates through (like a survey). After submitting the survey the app must return to the start screen, after which, they must not be allowed to navigate back to the screens which were previously shown.
What would be the correct way to implement this?
Currently I'm calling
UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
as many times as there were different screens. Is there perhaps a more elegant solution to get back to the start screen?
UiApplication.getScreenCount() will always give you the number of screens, so you can just do this (from anywhere, it doesn't even have to be from any particular Screen class):
public void popToRoot() {
UiApplication app = UiApplication.getUiApplication();
while (app.getScreenCount() > 1) {
app.popScreen(app.getActiveScreen());
}
}

VOIP App window (in foreground) blocked from receiving user input during Active Cellular Call

During an active VOIP call, my app is put into the background when an incoming cellular call is received and answered. If, while on the cellular call, I bring my app back to the foreground the app view appears but is unresponsive. The "Touch to return to call" banner appears at the top of the view in green but the app view appears as if there is a darker transparent window overlaid on top of it preventing the view from receiving input. If I put my app into the background, bring another app to the foreground and then bring my app back to the foreground everything works as expected so the problem seems to be specific to active cell calls and/or the green banner only? In Settings->Notifications->Phone I tried turning Notification Center OFF and Alert Style NONE in the hopes of removing the banner to see if the problem still exists but these settings do not effect that banner. In addtion to the App window appearing to have a transparent window overlaid on it, if I touch the window I'm able to drag the entire app window (or view) in all directions (up down side to side) and it has a bounce effect (like tableview vertical scroll) when I release it.
If I dont know the problem I cannot fix it (:
Thanks..
Are you sure there's no view being added on top your view which might be intercepting all your events? My second guess would've been that your app received a memory warning and unloaded a bunch of views. However, that's not very likely since you still see all the views.
I don't know what you really mean to "bring your app back to the foreground",but I can tell you for sure that you cannot call in the same thread the UI and the incoming call, so for situations like this when you want to render some view during a call you can try something like this:
public void InvokeGUIThread(Action action)
{
Dispatcher.Invoke(action);
}
For example if you want to set a text in a textblock do something like this:
InvokeGUIThread(() =>
{
textBlockSome.Text = e.Item.ToString();
});

programmatically get the time mobile screen was active in blackberry

I am working a core Blackberry application in which I need to detect the time for which screen is active and not blank or not coming in sleep mode after left un-touched.
I search alot, but didn't anything interesting. Please provide me some useful stuff or snippet so that i can proceed.
You can try onExposed and onObscured method of the class Screen.
protected void onObscured()
Invoked when this screen is obscured. A Screen is obscured when it is
was the topmost and is no longer by means of:
a new screen pushed on the display stack
a global screen is displayed above this screen
this screen's application goes into the background
this screen is pushed and it is deemed obscured by the above rules
protected void onExposed()
Invoked when this screen is exposed. A Screen is exposed when it becomes the topmost by
means of:
a screen is popped off the display stack
a global screen is popped
this screen's application receives foreground
this screen is pushed and it is deemed exposed by the above rules

Resources