MainScreen not pop after calling popScreen() - blackberry

I try to pop the main screen using
UiApplication.getUiApplication().popScreen(getScreen());
But after executing this line main screen not poped and my application hanged.
And I received the following message from console.
FocusHistory: Focus lost; App AppName; Component net.rim.device.api.ui.component.ButtonField

try to use
UiApplication.getUiApplication.popScreen((UiApplication.getUiApplication().getA‌​ctiveScreen())

UiApplication.getUiApplication().popScreen(this);
Or
UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());

Related

iOS: Dismiss presented ViewController which is an instance of specific Class

I am using NYAlertViewController to display dialogs in my iOS-App. It can happen that I just opened a dialog when a background process tries to trigger another dialog. If this happens, the second dialog is not shown. I would like to close all other dialogs before opening a new one. How could I do this?
The Dialogs are shown with presentViewControllerAnimatedCompletion.
Maybe I can dismiss all ViewControllers that are instances of NYAlertViewController?
Any thoughts on that? Thanks!

How to pop an alert dialog on Flutter from outside the builder

Consider my scenario
//Show the progress indicator inside an alert to block the user
showAlertProgressIndicator();
// Get the data
await DataManager.get().getDummyData().then((value){
// After data acquisition pop the alertProgressIndicator
});
How can I achieve this?
I think it should be simple
Navigator.pop(context); or
void closeAlert() {
Navigator.pop(context);//it will close last route in your navigator
}
I guess these 2 methods in the same build(). So they have the same BuildContext, so above should work.
I have created a sample app related to this situation. It is here https://github.com/Yahhi/flutter_dialog_test
Context is the same and dialog disappears after 5 seconds on timer event.
Navigator.of(context).pop();

UI Automation onAlert method not being called on simulator

Upon initial launch of my app, I get a permissions alert asking if I will allow the app to use my current location. My onAlert method successfully dismisses the alert on my device. When I run it on the simulator, it never gets called. Other internal alerts are handled by the onAlert method on the simulator. The permission alert coming from SpringBoard is not handled on the simulator. Any ideas?
UIATarget.onAlert = function onAlert(alert)
{
var title = alert.name();
UIALogger.logMessage(title);
return false;
}
This problem happens because the alert you're seeing comes from the system itself -- before the app actually launches and your automation environment is initialized.
To see this happen, add a debug line before the function definition for UIATarget.onAlert:
UIALogger.logDebug("Now setting up the alert function");
UIATarget.onAlert = function onAlert(alert) {}
Next, Reset Content and Settings... on your simulator and re-run your automation. You should notice that the debug line will not appear until after you manually dismiss the alert about using the current location.
I do not see how this would be fixable from javascript code. You have to delay the alert until the app has properly launched, or follow the example shown in this answer.
If default handler is not working for you, then you can simply use 'return true' instead of the 'return false' so that you can manually dismiss the popover.
Before 'return true' statement you can write some statement for tapping the button (dismiss button) you wish to.
I had the same problem with an app that presents an alert immediately after launching. When I logged the element tree, I could see the additional alert window, and I could let UIAutomation tap the OK button in the alert. But the alert handler was never called.
The reason was that the alert appeared before UIAutomation was set up properly to handle it. If I delayed the presentation of the alert, UIAutomation did catch it.

push modalscreen called my noneventherad

I know this is very basic, but I am not able to figure out why I am getting this.
I am running a splash screen, and in the splash screen I am running a background thread for performing my required operation to contact server.
After the background thread finishes its task, the listener in the splash screen creates an object for the next screen and sends it to the method below:
public void swapScreen(final TopNewsScreen _tn)
{
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run()
{
UiApplication.getUiApplication().popScreen();
UiApplication.getUiApplication().pushScreen(_tn);
}
});
}
Help of any sort is welcome.
The code you posted looks fine. I've seen "push modalscreen called from noneventhread" happen when there is a Dialog.inform or Dialog.ask call somewhere on a background thread.
Double check your background thread, and make sure it doesn't try to throw up some UI.
popScreen() takes a screen as an argument, so there should be one there.
When the last (or only) screen your application has pushed to the display is removed, the application exits. I would suggest pushing _tn first, then poping the splash screen.
The better way to handle this situation is:
class SplashScreen extends FullScreen
{
protected void onObscured()
{
close();
}
}
And simply push your screen (TopNewScreen) like you are doing. When the SplashScreen is not shown anymore, the screen closes by itself.

What is the best way to create a loading screen class for a Monotouch App?

I need to load and process many things before my app starts, so when I test it on my iPhone it's always killed by iOS because it hangs the iPhone for too much time.
I then decided to write a loading screen class for my Apps, something that shows immediatly a logo and a progress indicator (keeping it responsive to avoid being killed by iOS), while in a background a separate thread initializes all my ViewControllers and then closes the loading screen and shows the main window.
What is the best way to do it with MonoTouch?
Any suggestion is welcome.
Thank you.
This is how I do it:
In the FinishedLaunching method, initialize and add your splash view to the main window:
window.AddSubview(this.splashView);
After that, invoke your code that does all the stuff you want to do in a thread/async invocation. I usually use the ThreadPool. Remember to invoke on the main thread:
ThreadPool.QueueUserWorkItem(delegate {
this.BeginInvokeOnMainThread(delegate {
//Initialize stuff here
//...
//when done, add your initial view to the window and remove the splash view
//eg.:
//window.AddSubview(myController.View);
//this.splashView.RemoveFromSuperview();
});
});
// show the window, which only displays the splash view now and return
window.MakeKeyAndVisible();
return true;
A rough example, but I hope it helps.

Resources