FLAG_KEEP_SCREEN_ON not working when showing an alert dialog on wear os - wear-os

I am developing an Wear OS App, that requires to have the screen always on for certain tasks.
To achieve that, I use window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
It is working fine, but when I show an Dialog, the screen turns off after a few seconds.
I do not want to increase the timeout , but instead I need to keep the screen on while the dialog is showing on the screen.
I tried to use android:keepScreenOn="true" on my activity and it's working fine until I show Dialog.
There is how I create dialog.
val binding = ProgressLayoutWithTextBinding.inflate(LayoutInflater.from(context))
val dialog = Dialog(context)
binding.textProgress.text = message
dialog.setCancelable(false)
dialog.setContentView(binding.root)
dialog.show()
I'm using galaxy watch 4 (SM-R880)
Has anyone encountered this problem on a watch?

Yes, I've had this problem.
Solved it by
dialog.show()
dialog.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

Related

How do I make and code a splash screen for an app in NativeScript (Angular)?

I'm trying to put an Splash Screen on the app that Im developing on NativeScript with angular, the problem is that I don't know how to create it and then implement it on the app.
What I want is just a screen that shows when I hopen the app and then just goes into a login screen (already have the login screen).
Checkout nativescript-splashscreen if you like to customise splash screen with cool animations & components.
Edit: If you are looking for a loading indicator to let user know you are processing something or waiting for a network call, you could use nativescript-loading-indicator Or even host your own dialog if you need something more customized.
You can use loader kind of mechanism if you want to just put some content for sometime you can add content on loader screen and it will be shows for defined time
you can use ngx-ui-loader npm package for this
else you can create new component and make it as dailog window that will open on login page loading and than it will be closed by click or timeout. you can use different NPM library for this.
This both approach might solve your splash screen problem.

Xamarin forms Android app verison goes blackscreen randomly

I got this app im been working on i xamarin forms. where i use a ContantPages inside a navigationspage. like shown below
MainPage = new NavigationPage(new SwipePage());
Now when i navigate to a other page like shown below, sometimes the screen goes black. If i then tap out of the app, and then tap in the app, the black screen will disappear, an the page content would be showing. making the app normally again.
this.Navigation.PushAsync(new ProfilPage());
I been trying to see if it's curse i load more data en app start, then resume. but i don't. its getting the same amount of load on resume, as on start.
So do anyone have a idea what it can be, or have tried something similar before?
Thanks for your time,
---UPDATE---
So In a emulator it runs without problems. but when i use a android device IRL it's keep doing that black screen thing.
I think this is occurring because you are not awaiting the async method thus showing a black screen as the page is still rendering but you have already been pushed to the page.
Try using the await operator.
var page = new SwipePage();
await Navigation.PushAsync(page);

Issue while setting WindowSoftInputMode to AdjustPan

I’m working on Xamarin forms project. I’ve many Entry fields in my application, one of them is in popup and the popup opens in the centre of the device screen. Also few entry fields are in scroll view. The issue is only with the Android Application. For iOS it’s working perfectly.
When I click on Entry field in side the popup, the soft key board is opened and the UI of my popup gets disturbed. So, I decided to set
WindowSoftInputMode = SoftInput.AdjustPan to my main Activity. This solves my UI issue of the popups but now when I click on other entry fields,my ![scroll view stops scrolling] (few entry fields are in side scrollview).I tried by using AdjustResize and rest of other soft inputs, but of no use.
Any ideas on how to get rid of this ?
On Android Xamarin.Forms Application is working on a single Android Activity, so WindowSoftInputMode is set globally. You could do a dependency injection service. On iOS it would do nothing and on Android it would set WindowSoftInputMode to your desired value. Then use it to set WindowSoftInputMode before and after showing your Popup.
In Xamarin.Forms Forms.Context is the Activity.
var window = ((Activity)Forms.Context).Window;
window.SetSoftInputMode(SoftInput.AdjustPan);
In case of
Xamarin Android
you can access window directly from mainActivity Like so:
Window.SetSoftInputMode(Android.Views.SoftInput.AdjustPan);
or in AndroidManifest.xml
<activity android:name=".myActivity"
android:label="#string/app_name"
android:screenOrientation="sensorPortrait"
android:windowSoftInputMode="adjustPan"/>

Qt OSX Incorrect Mouse Behavior

My application uses OpenCV, OpenGL, and Qt to display a webcam feed. It works perfectly on Ubuntu (clicking buttons works properly), but on OSX there seems to be a UI problem. The window displays, but I can't click and I quickly just get the loading spinning pinwheel and it doesn't stop until I force quit the application. Has anyone come across this problem before?
I solved this by adding a timer to the initialization of my gui widget:
m_timer = new QTimer();
connect(m_timer, SIGNAL(timeout()), this, SLOT(gotNewImage()));
m_timer->start(1);
where gotNewImage() is the function I call to grab a new image.

Windows Mobile 6.5 - camera life preview and image capture using my own dialog

Im writing an application for workers in our factory and one of requirements is that they should be able to take images using camera integrated in PDA with WM6.5.
The main difficulty is, that thay MUST NEVER EVER be able to enter windows, Start button, desktop etc. They are allowed ONLY to see my fullscreen application.
I succesfully deactivated BlueTooth + red, green and volume buttons (if you are interested, im pasting links here)
http://forum.xda-developers.com/showthread.php?t=546737
http://msdn.microsoft.com/en-us/library/bb431750.aspx
http://social.msdn.microsoft.com/forums/en-US/vssmartdevicesvbcs/thread/a4f9f41d-47a8-4080-8613-2c2ddcf4c012/
And now I have to implement the camera function. But as CameraCaptureDialog opens a new dialog and shows start button, task bar and allows user to open list of applications, I must not use it.
I must create my own dialog that will show the Live Preview in a panel or in an imageBox and photo will be taken using a button.
I searched the whole internet and found only DirectShow.NETCF (but people do not recommend it) and CameraCaptureDialog.
Can I somehow redirect the CameraCaptureDialog to my dialog? Or can I access camera directly via .NET framework? Or can I modify the CameraCaptureDialog not to show Start button, menu etc?
Looks like you have a bit of a challenge. I agree that Directshow is a questionable solution, but it may be your only option. I did get http://alexmogurenko.com/blog/directshownetcf/ to work, but only on low resolutions.
A better option might be to find a device that does not show the menu bar/start button. AFAIK, the HTC HD2 has a very clean Cameracapturedialog..
Good luck.

Resources