Imagine I would be trying to implement a button in my Flutter App. After the button is pressed once, it is supposed to be "deactivated" for 8 hours. After 8 hours, the button should be able to be clicked on again. How can I implement this?
How can I make my Flutter App recognize the time? Do I set a counter? Does the counter continue to "work", even if the app is closed? Do I need a database?
Any help is appreciated.
I tried to find something on Google, but I did find any clear explanation... ☹️
You should be able to accomplish something like this by getting the current date time on a button press and persisting it in a simple key/value store so that you can read it through an app restart
Related
So my question is fairly simple, but I cannot find a solution of the entire idea. Running Android App in background should be achievable with Background Service . However, I am not sure how to make "wake up" the service by a specific button press combination.
DUMMY EXAMPLE:
// My app is installed and launched on the device and is running in background since it got installed
void onCorrectButtonCombinationPressed(){
startActivity(someIntent);
}
How to achieve the above scenario ?
Thanks for suggestions and I apologize if there is something silly that I missed out, because to me it sounds easy to do, but I am struggling to figure it out..
That depends on what you mean by a "specific button press combination"
If you want to detect clicks or button presses from your own activity, then handle it within its respective view through standard event handlers.
if you want to detect clicks or button presses from OTHER activities, give up! There is no means by which you can achieve this through (standard) methods. If you root your device you'll have more power to do something like this, but I did some deep research and found no other ways. The reason for this is because imagine how easy it would be to steal information from activities if you could intercept events being sent to it.
I asked a question the other day that may give you further information.
I have a project in where the Android application should receive and send sms. I just want to update the textview because the button visibility will depend on the textview.
Like, if the application receive sms with 'ON'. The on button will show. And the off button will hide. And otherwise.
I also used SharedPreferences to saved and resume the last state of the application whether it was being close or maybe the device is turned off.
The problem is that, I dont know how to make my application update and saved by SharedPreferences while it is not using by the user. Is it possible?
Please help for the best way to solved this problem. Thank you in advanced! :)
I want to create an Android application for conducting Quiz (at University level). While the quiz is progressing, I don't want users to go out of the app and search Internet/use any other app and answer. I dont want the user to exit the app unless they explicity submit/exit the quiz upto what they have done.
I have tried making it as launcher app but I couldn't take control of task switcher button. Also, I was not able to disable notification area.
If I cannot restrict this much, I want to monitor what they are doing while quiz is progressing. I can get any permissions or be device administrator or anything but I cannot restrict internet access as the server of the quiz is in internet. If a call or notification comes, I dont want that to popup while quiz is progressing etc.
Atleast, I want to log everything to server if they have done anything intentional. How can I achieve this?
Thanks
listening for onStop in your Activity might do the trick.
see: https://developer.android.com/training/basics/activity-lifecycle/stopping.html
You can finish the activity in onStop() or you can use this on the activity in AndroidManifest.xml
android:launchMode="singleTask"
android:noHistory="true"
I am developing an Android application, and I want to show some tips (few slides) for user when applicationis started first time.
I can make an activity and start it in OnCreate method of main activity, or make dialog window.
I want to ask: how to make it in the right way? Can experienced developers advise something, maybe with example?
You have to first make sure that these tips are launched only on first launch of app. I have seen this done by displaying a Dialog, and saving a value to shared preferences (or in sqlite for that matter). On next app launch this value is checked, if it is set, then you don't display the Dialogs.
This seems to be the simplest way. Note that when the app is uninstalled and installed by again the Dialogs will be displayed again.
Sometime we want to give the user ability to see this Dialogs once again. You can do this by setting/resetting the value in shared preferences from the apps settings screen. The user can change the value here and see the Dialogs again on app start.
Just make a Dialog Type Activity and show it automatically at the first time startup of your application.
and also add a help in you menu so that user can see it whenever he/she need help.
Can someone point me in the right direction to have an Android Application reopen itself to the forefront after a user has pressed the home key? It should be able to be linked to some kind of countdown (which I already have setup, and runs when pushed to background).
I just can't find the function to force this action
*And yes, this is what the user will want, don't worry, I know this doesn't sound user friendly (forcing open) but in this case the user wants it.
Thanks
I needed the exact same thing before -> an app being displayed upon an event but I was sure I read on the Android developers site that this can't be done and that's what notifications are used for, although starting a new activity does bring an app to front. I found this link however to a NEW_TASK_LAUNCH flag with startactivity that might solve your problem -
http://developer.android.com/guide/appendix/faq/framework.html#4