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());
}
}
Related
The multitasking features got updates in iOS 11, one of those was slide over which is demonstrated in the gif below.
With these changes it's no longer possible to use the techniques that check frame size from iOS 9 to detect if another app is a "slide over" over my app.
Is there any new method to detect if another app is running as slide over?
I was able to get this working fairly easily on an iPad Pro (which supports side-by-side apps, not just slide-overs). Here's the code:
class ViewController: UIViewController {
override func viewWillLayoutSubviews() {
isThisAppFullScreen()
}
#discardableResult func isThisAppFullScreen() -> Bool {
let isFullScreen = UIApplication.shared.keyWindow?.frame == UIScreen.main.bounds
print("\(#function) - \(isFullScreen)")
return isFullScreen
}
}
The end result is that it will print "true" if the view is full screen and "false" if it's sharing the screen with another app, and this is run every time anything is shown, hidden, or resized.
The problem then is older devices that only support slide-over. With these, your app is not being resized anymore. Instead, it's just resigning active use and the other app is becoming active.
In this case, all you can do is put logic in the AppDelegate to look for applicationWillResignActive and applicationDidBecomeActive. When you slide-over, you get applicationWillResignActive but not applicationDidEnterBackground.
You could look for this as a possibility, but you cannot distinguish between a slide-over and a look at the Notifications from sliding down from the top of the screen. It's not ideal for that reason, but monitoring application lifecycle is probably the best you can do.
I'm writing an iOS app that casts pictures. I want to make it in a way that when the user quits the picture viewing scene, it goes back to the homepage (the one displaying app's name) on the big screen. I've tried calling the stop method for mediaControlChannel and it's not going back to the homepage. So apparently this is not the one I'm looking for. So which method should I call to make it go back to homepage?
SDK doesn't have any understanding of your "homepage"; that is a concept in your app so you need to write your receiver so that if user ends the process of viewing picture, it switches to that page. Whether receiver on its own can determine that the above process has ended or sender has to signal the receiver depends on your application and its details but regardless, going to your home page is an action that you have to define and handle.
I want a password protected settings screen for iOS. For that when the user navigates to the settings screen I hope to popup a UIView and ask for the password. For that I want to know two things
How to detect the user has moved to the settings screen.
How to pop up my UIView(or else at lest an alertview) within the settings screen.
Simple answer is: you can't. Incorporate the protected settings within the app.
That's not possible, your app works on its own scope, you cannot monitor or control in any way what the user does in the phone outside of your app.
My iOS 4/5/6 app is meant to be used briefly. I want the user to click a "Done, now go away" button which takes them back to the app they were using before mine came to the front.
Is there a way for my iOS to put itself in the background while returning the previous app to the front?
On an iPad, the user can get that effect by doing a four-finger swipe horizontally across the screen. But that gesture is not a complete solution because (a) that gesture does not work on a handheld device, and (2) not many users know of that gesture. I want to programmatically return the previous app to the front.
I want the user to click a "Done, now go away" button
That button is the Home button.
I want to programmatically return the previous app to the front.
There's no public API for switching to another app. Users have a number of options for switching between apps, though. In addition to the swipe gesture you mentioned, they can do a four-finger upward swipe to get to the list of recent apps, or double-tap the home button for the same effect, or hit the home button once to go back to Springboard. Users, not apps, are supposed to be in control of which app is in the foreground. And the way they do that should be standard from one app to another. I can understand wanting to make life easier for the user, but what you're trying to do just isn't possible with the available API.
I Don't think you can do that if the previous application is not your property or if you are not aware if a URL Scheme has been incorporated in the previous application that you know of.
Launch App Via URL Scheme!
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