I want to block my screen for listening a tap or click when the show.status("Please Wait",2 AnyTimeLimit); is invoked.
Actually I'm sending a hit to a web service and meanwhile I'm displaying a message "Please Wait" with 2 seconds wait. But after those 2 seconds It starts listening the tap/click. How can I block them to listen tapEvent/ClickEvent when displaying message?
Thanks,
You will have to make a custom screen that overrides PopupScreen for that. In your implementation, you will have to override onUiEngineAttached, like so -
protected void onUiEngineAttached(boolean attached)
{
super.onUiEngineAttached(attached);
if(attached)
{
// start server hit thread, which closes the screen when done
}
}
After that, just push the screen using UiApplication.getUiApplication.pushModalScreen(). You will want to keep the data you received in a byte array somewhere in the screen's instance which you can retrieve by calling a getter once the screen has been popped.
Related
I am trying to record a UI test case and run it back, but I am running into this error. Basically, in my application when I land on the home screen, the user is asked to allow use of notification and location. After I record these events and try to segue to another VC, it records normally like so.
[app.alerts[#"\u201cSampleApp\u201d Would Like to Send You Notifications"].collectionViews.buttons[#"Don\u2019t Allow"] tap];
[app.alerts[#"Allow \u201cSampleApp\u201d to access your location while you use the app?"].collectionViews.buttons[#"Allow"] tap];
//segue to VC2
But when I play it back, it fails with the error in the title.
Did not receive view did disappear notification within 2.0s
I suspect that by the time the alerts are cleared, the segue button is already tapped and while it expects the home VC to disappear, it does not. Is this understanding right?. If yes, how can I delay the expectation, if no, please help.
System level alerts should be handled by addUIInterruptionMonitorWithDescription API here is the documentation from apple Link and sample code in swift below:
addUIInterruptionMonitorWithDescription("First Dialog") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}
XCUIApplication().tap()
I have a blackberry application in which i want to show a "please wait" modal screen(which is a FullScreen push as modal screen) while sending a server request and if the user hitting the device back button , pop the modal screen and current active screen.This works fine.
My problem is that : I used a callback for server request in the active screen.But the callback executed even after popped up the screen.
Exactly whats happening while calling popScreen()? How can i remove all callbacks and refresh the screen if the user pressing back button while server request happens?
Thanks in Advance
There are several solutions to this problem of course. I guess the server request is sent asynchronously.
The simplest way I think out is having a flag and when the callback
is triggered check whether the user cancelled the action (pressing
the back button).
Another solution, perhaps not that nice is to check whether the
Loading Screen is still in the display stack.
What I think would be a proper solution is to have a stack of
cancelled http operations, so you can stop requests at any time. Then
if the request to the server has been sent, before calling the
callbacks you can check if the operation has been cancelled.
Otherwise, you just avoid sending the request to the server.
When you call popScreen, the screen which is on top of the display stack (the screen in the foreground) is removed from the stack and the Screen is refreshed (a paint event is triggered) to reflect the changes. Make sure you execute Screen.pop() on the UiThread:
UiApplication.getUiApplication().invokeLater(runnable)
In your scenario, how is the callback handled? Is it a delegate you passed along with the request or is a listener you register?
When I refer to delegate I mean something like the following:
Server.sendRequest(request, objectWithCallbacks)
and callbacks of the objectWithCallbacks (and only objectWithCallbacks) will be called accordingly. On the other hand, a listener would be something like:
Server.addListener(objectWithCallbacks, request)
Server.sendRequest(request);
this way, all the objects listening to "eventName" will get their callbacks triggered accordingly.
As far as I see, your callback will be always executed but in the callback itself you can check if the screen is currently displayed.
if( this.isDisplayed() ) {
// Do the magic
}else{
// Do nothing
}
Good Luck
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();
});
I have written a function named as register which connects with the server and calls register done method (if connection established successfully) which is a delegate method,now here i am trying to display alertbox but the UI gets stucked and the glow appears but the alert box doesnt?
Could anyone help me on this?
You are trying to show the alert from background thread you should not do that you need to show the alert from the main thread
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.