I am working on an application where I have to launch activity asking user to enter login and password to proceed further. The user will get option to save login/password. If user saves login and password, the application will not show login activity at next launch and instead should go directly to the main application screen.
I am thinking of starting application with Application class object and checking stored preferences to decide which activity is to launch. For some reason, application class is not launched, it may need some extra thing in manifest file.
Any suggestions what would be the best way to implement this kind of behaviour.
Thanks
Bsengar
Any suggestions what would be the best way to implement this kind of behaviour
A splash screen is often used for this. Your first Activity (splash screen) can display your logo/and or play music or whatever while you check your data and decide which Activity to go to next like login or main Activity. This usually shouldn't be displayed very long (maybe less than a second or so unless doing network stuff such as authenticating/loading data).
...and checking stored preferences to decide which activity is to launch
This is often how people handle this. You can check SharedPreferences in your splash screen to decide which Activity to start. If the login is stored then go to main Activity. If not then go to your login Activity.
Make sure to call finish() in your splash screen so if the user presses the back Button from login or main Activity they will exit the app instead of going to the splash screen again, unless of course that's what you want.
Good example of getting started with SharedPrefs in case you aren't familiar.
Full Docs for SharedPrefs
I wrote an application that does something very similar. In my case, I use a "remember me flag" that allows the user to indicate that they want the application to save the login id and password. If they elect this setting, the application will save the login information in preferences and pre-fill the login screen the next time the user launches the application.
Related
I want to auto-login every time the app starts, I am using FirebaseAuth, so my userid is auto-fetched, but it goes to the registration page directly, I want to check if the user exists or not if it exists, move it to the home screen else to the registration page.
I know what to do, but where to check this and so navigation?
What you're looking for is what we usually call a Splashscreen.
That's the screen you usually see on huge app's startup, with a loader.
On this screen, you can do all the stuff that is required for your app to run correctly :
Preload your images.
Load some datas from an API
Check the user's state
That's the good place to choose to redirect your user toward the most appropriate screen
What is the best place to set up apps initial version checks and update shared preferences or load initial data from the database in flutter apps?
Because I want to update some shared preferences on app load, even it's from the background.
I usually use this logic:
To let the app startup be as fast as possible I do all checks in in first page after user log in.. usually that page is my main page.
So I do this
splash
check preferences and if there is a user I log it in
after login sucvesfull I go to mainpage
if there is no user in preferences I go to loginpage
first method in login and main is where I check versions, do user login ecc
So you can let user open app super fast and only after app is rendered I do checks.. so user has the impression your app open app really fast.
Bye :)
If I have a login screen and then the activity which displays the main functionality of my application.
Which one should be deemed as the default=launcher activity?
Should I have the login screen as launcher which will be skipped if the username/password exist in the preferences?
Or should I have my Main activity as a launcher which should start the login activity if no user/password are present?
I have found the following google guiding lines:
http://developer.android.com/guide/practices/design/seamlessness.html
Look at the title: Don't Overload a Single Activity Screen
I am not sure that I have understood it correctly, but if I did, then it means that the login screen should be the launcher screen.
Am I correct?
What do you suggest?
this is a common sense what to do.
On successfully login save username and password in sqlite database or save in SharedPreferences. and check data allready exist in side oncreate() method og Login Activity
if username and password exist in SharedPreferences or sqlite database. start your activity in which you have main functionality.
I am designing an iOS application where a user is presented a "sign out" button as the client wants that to be there.
However I am having a tough time working through the logic.
Should I:
1). exit the application at that point since the entire app runs on the premise of authenticated web service calls. (if so how do I make my app exit? )
2). Take the user to the initial splash screen where he/she is given the choice of login/register. (if so how do I reset the app back to initial screen?)
I know what I am asking is confusing so I hope I am making sense.
Exiting from the app is not recommended. It would give the feeling of app crash to the user. You may use the second approach of sending the user back to the initial login screen after he sign outs. If you are using a navigation controller based approach you can try using popToRootViewController method of going back to the login screen(assuming login screen is your root).
Exiting the app is definitely not a good option. I would suggest you take the user back to the page where the user has the option to login or register. As an end user if he/she want to sign in with a different account if he/she can, it would certainly be the best option. No user would want to exit the app and launch it again to use them.
I'm creating a web application meant to be viewed by iPhones, Blackberrys etc. My problem is that, when an iPhone user adds a link to the app on their home screen, they have to log in twice.
The cycle goes like this:
User bookmarks the app's homepage
User later goes to the homepage
They are brought first to the log in screen
After logging in, they are taken to the app's homepage
As soon as they click a link, Safari opens a new window in which they are brought to the log in page again
After logging in this time, everything works as normal
It seems like a problem with Session variables, though I can't seem to find any sort of elegant solution for it.
Also, the server is running ColdFusion.
Would it be possible to drop a cookie when the user first logs in?