programmatically get the time mobile screen was active in blackberry - 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

Related

How to add a view/gesture recognisers to iPhone/iPad home Screen

Until today I believed that it's impossible but there is an app is called Shou from the Emu4iOS Store that record your screen and even if the app is in background there is a view on home screen that on touch redirect you to the app. (please see attached image)
My Question is how can I achieve the same ? How can I add a view to Home screen ?
That's a status bar in a recording state. These are system defined states, such as the green bar you get while taking a call. These appear when an app is recording audio automatically, and there is no way to trigger it manually.
There is no way to add views and gesture recognizers on to the springboard.

Lock screen compatible with modals

My iOS 8 app has a custom lock screen (a UIView on top of other UIViews within the same UIViewController). When the app goes in the background, the lock screen is displayed, hiding all other content.
The issue is that my lock screen do not appear on top of modals. When the user unlocks the app, I want the app state is be identical to when he left, so I want to keep the modals alive during lock.
How can I make my lock screen UIView appear on top of modals?
Make your lock screen a window and position it in front of all modal system windows, see the View Programming Guidelines for details.
tl,dr:
lockWindow.windowlevel = UIWindowLevelStatusBar + 0.05f:

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.

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();
});

Pop to home screen

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

Resources