i am developing a app for lock screen.
But i have to show a black screen so that auto timeout can occur so the user can use normal unlock methods.
but the problem is if user touches the screen then auto timeout resets even though i had set the whole screen layout untouchable using this :
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
Can anyone tell me how can the screen timeout happen exactly after the set time and the timeout runs as soon as the activity is created and dos not resets when user touches the screen.
Related
I'm setting my screen to be always awake in order to preventing it from going into sleep mode at all.
hence, when the screen display is turned off, the user has to touch the screen in order to bring it on again, but the problem is that this touch is received by the foreground activity and it reacts according to it, and the user is for sure just trying to turn the screen display on.
I tried to set the following flags but didn't work:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
&&
getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
To resolve your issue you have to do one of the below things which prevents screen to turn off automatically.
Add android:keepScreenOn="true" to some widget in your layout XML resource for this activity. So long as that widget is visible on the screen, the screen will not turn off automatically.
OR
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
to disable the screen timeout and
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
to re-enable it.
I'm using the following line of code on the onCreate() methods of my two activities:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
The point of course, is to keep the screen turned on and undimmed.
The point is that if the screen is dimmed -not turned off- before one of my activities is launched, the screen will maintain it's dimming until the user touchs the activity. After the user interacts in any way (TouchEvent or something like that, I'm assuming) with the activity the device will undimm the screen and maintain it that way until the user leaves the activity.
Does anyone knows why this is happening and how can I undimm the screen of the device before setting the FLAG_KEEP_SCREEN_ON flag?
I'm customizing my app to provide a better experience with the Kindle Fire.
in this device, if you do in your Activity
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
the soft bar with the back, home and setting buttons disappear, and only appear when the user presses the "fullscreen handle" the soft button bar is back on screen.
https://developer.amazon.com/sdk/fire/screen-layout.html#StatusSoft
I want to detect devices that have this behaviour, this is, devices that have not a physical back button or a permanent back soft button, so I could set up the window differently in these cases.
I'd like to do it programmatically, and avoid having to declare a config property (and thus maintaining more than one apk).
Thanks.
I'm having a problem where an EditText in landscape/full screen mode becomes empty after turning the screen off and then on when the system Screen lock is set to None. The keyboard remains active, but it doesn't appear to have focus and no text updates are displayed on the screen. If I tap the Done button or rotate to portrait, then the full screen editor is removed and I can see the previously entered text in the normal EditText view.
I'm reproducing this on JB in both the emulator and a device. The EditText has an android:id and I've found this problem with a variety of EditText and AutoCompleteTextView configurations, but only when the system Screen lock setting is set to None. Everything works fine when it's set to Slide or Pattern, so I suspect that the lack of a screen lock is the source of this problem.
I found the same problem in Calendar, but not in Messaging. When editing an SMS message in landscape/full screen mode and then turning the screen off/on, at first the message appears to be empty, but then it returns after a second. I reviewed the source code below, but I didn't see anything special in onResume() that appeared to be addressing this issue.
https://github.com/android/platform_packages_apps_mms/blob/master/src/com/android/mms/ui/ComposeMessageActivity.java
Does anyone know how to properly fix this, so that when Screen lock is None you can edit text in landscape/full screen mode, turn the screen off and then back on, and the text is displayed just as you left it?
As a (hopefully) temporary fix, I have included the following line in onResume() and it appears to do the trick. Initially I tried to only run this when the IME isFullscreenMode(), but this returns false in onResume() (after returning true in onPause()). I would guess that this is part of the root of the problem. When system Screen lock is None and the screen is turned on, the IME doesn't know that it's in full screen mode when it actually is.
View view = getCurrentFocus();
if (view != null) {
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
.restartInput(view);
}
my android app is displayed fullscreen.
to be 100% sure I did this in code with:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.findperson);
and in xml with
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
whenever my screen turns off for power saving, and i turn it back on again, the statusbar is back and does not want to disappear. How can i make it disappear forever (or for the duration of my app)?
edit:
okay, i did find some more info this:
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
interferes with the fullscreen setting.
I know we are not "supposed to" override the homebutton. However, I am desiging an app that is exclusively used on the phone. in other words, the phone should lose its phone function and only show this app.