I am developing a simple screen lock application.
I want that when I click on the app icon the screen gets locked and turns off. And am also able to do that, BUT before locking the screen the main activity gets launched (Set to Theme.NoDisplay) which takes time to get the device locked, which I don't want to happen.
So is there a way that I can turn off my screen (OR do something like starting Torch) without launching the app activity. If required I can also provide the code which i am with.
I think what you are looking for is android widget.
Related
I observed one behavior in fire stick, apps which are present in main screen are always calling onDestroy on app launch, which cause app to restart and not launch where user left off.
I checked with Netflix app, even there onDestroy gets called on launch but they are preserving state before app close, and so able to launch from last exit state.
My doubt is, why fire stick treats main screen apps differently? I searched but did not find proper answer. Mostly people talking about is memory getting full which is not the case here.
I'm developing an Android app with several types of alarms and triggers.
One of these alarms trigger if you stop moving (GPS tracking) while it's active.
Now, when the app runs in the background when this triggers the client doesn't update when you switch back in, and the only notification received is a push-notification from the backend service. If I enter through the notification, the client loads the alarm correctly.
The code base is quite extensive, and due to time and resources it would be best to avoid huge refactoring tasks.
Is there an easy way to make the app go from Activity A to Activity B when it's running in the background?
You cannot change the current Activity in the background without bringing the app to the foreground (using startActivity()). However, you can surely tell the app that when it is brought to the foreground it should start a certain Activity or rearrange the back stack or whatever.
Post some of the code and maybe we can help more.
I need to know how to keep the user (child in this case) from accidentally hitting the home button and others closing the app. I want a parent to be able to hand the baby the phone and as she/he taps it will make sounds. That's all. My little one is my beta tester and she keeps closing it unintentionally then getting mad. I'm using android studio with ics+ support.
Although it is possible by overriding the onPause() method, or relaunching the app when closed, both shown here.
I would recommend checking if the phone is running 5.0 or higher. If it is, then show how to use screen pinning, which requires the overview and back buttons to be held together for 5 seconds - something which a small child is unlikely to do.
I've a problem with my app, when I press side standby(screen disable) button when app is opened and turn on screen again and unlock my app is now in background, also, when I reopen it from background it restarts with loading screen(so it loose my previous app state and reset it). But when I place my app in background going to home and reopen it, it start from where it was when it goes in background. Same if I close screen when app is already in background.
How can I solve this problem?
Android usually keeps your app on the foreground even if you press on the power button (side standby).
Try using the SavedInstance as mentioned by Abo Hani.
Otherwise,
Try testing the app on other devices with different android versions.
Android only sends apps to the background if it needs more resources(memory,network,etc) to process other apps. Sometimes it might also kill the app.
I am developing an app which requires the gdk program to continue running as-is even after the device is removed from the head. Currently the program is paused when this happens seemingly by default, but I need the program to stay running because it is constantly uploading video. The desired result is that the program will continue to run and upload a video stream even if the glass is removed from the user's head.
What can I do to change this behavior?
thank you.
You probably want to perform the long running upload in a background service. Android's activity model makes it such that you can't really depend on the life of the activity to always be in the foreground and you need to use a service for tasks that shouldn't be paused.
Also if you have an activity you want to return to when you put Glass back on, ensure you specify android:immersive="true" within your declared <activity>. Without this, your activity could be completely destroyed when the screen turns off.