Android new Application (registration process) - android

I built an android application that registers the user with its username/Password/phoneNumber.
if the user is registered in the DB, he can see the other menus for the application.
How can i check if the user is registered or not on the application ? There is a good way to do that (propose the registration process or application menu) ?
Thanks

I would advise you to use JSON method you'll have to add php file in order to send the data from the android application to your database ( you'll make an Insert into for a registration or just a Select for an existing user in you php file) then JSON method take back the data to android and return TRUE or false I know it's vague but there's lot of tutorial on this method. Hope it helped.

I'm not entirely sure of what you mean by "how can I check if the user is registered" when you just said the information is stored in a DB.
So... Based on the information you provided, you can do a couple things:
Check the DB to see if the user exists / is registered.
Use SharePreferences to store a variable saying whether or not the user has registered and then acting based on that information: http://developer.android.com/reference/android/content/SharedPreferences.html

Related

Unique Number Creation and Database Registration

I want the application to create a unique 4-digit code and save it to the firebase database. This code will not change when the app is exited and entered again.How do I do that?
Example Image
Starting talk about the combinations.. this type of code (4-digits) can give life to only 10.000 users. If your app has 10.001 user, probably it will crash or will be unusefull.
Avoiding talk about the combinations, instead, firebase can't do this with its API or premade functions. You need to implement this with you code, in the android app or (recommended) in some "Functions". If you don't need that this code is random, you can have a field on your database that do as a counter.
Every time an user need that his code to be created (for example on registration), you simply retrieve the counter value on the db and increment, assigning it to the user code field. In this way, the first user of your app will be the code 0000. The next, will have 0001,0002,etc.. The last user that can be registered will have the code 9999.
As said above, retrieving the user data from database after the registration, you'll have the previous saved user code too, so it will not change.
If you need more help, please tell us more about your app or scope.

Write cloud code in Parse to check for unique username - Android

I am trying to check if an username is unique in the Installation class of my Parse collection. I figured out that the installation class cannot be queried like the normal classes and should be cloud coded to obtain result.
I had seen this post. How to check Unique fields in a class using cloud code. I don't know how to replace this with what I require and make a call from my android device.
My requirement is that, I just need to check if a given username is already present in the Installation class or not.
Thanks in advance.
Best way is probably the one described in the post you linked to. You shouldn't try to determine the uniqueness of the name on the device - you should do it on the server side while creating a new instance of your installation class, and return an error to the app if it tries to create a username that already exists (like in the example you posted).

Doubts in android

I've watched the Coursera android course and I have doubts how Android works in my application that I'm building. It does basic stuff, like register and show my info and do TODO using server as database. And I know it depends how I want to it begin built. Need some options.
Fragments can be built in ActionBar and whenever I want be called? Or is it bad to this way and stick with default menu built and hide it programmatically? Tried to google and didn't find any information.
The MainActivity is made to make http request POST to register name, email and password in my server. Is it possible to start the SecondActivity whenever he logged in? It's just like Instagram. But, I could set a condition to check depends if logged or not change the setContent(R.layout.main) or setContent(R.layout.second)?
When the register is done. All the data is saved on the server. But I want to check every time he changes activity or do some action if he's logged in or not. Could I use some thread with a flag(bool)? Could be a bad practice and reduce the performance? Or SharedPrefrences adding flag(bool)? But SharedPreferences are saved after the application is closed?
About to show my information in every Activity, like name, age and sex etc and such. Making request http just to show information is quite bad for my application, since it's just TODO app and I don't need to be connected to internet to see my info, but in case of edit, yes. So if I save in the SharedPreferences, but stays the same doubt, it will save after I close the application?
Since your question is likely to be drastically edited (as i advised in a comment) i quote the original text here.
Fragments can be built in ActionBar and whenever I want be called? Or
is it bad to this way and stick with default menu built and hide it
programmatically? Tried to google and didn't find any information.
Yes, fragments can be used whereever you like. But thats not really an answer.
Base your design on the various activities (think "what app screens should users navigate", and give these one fragment each.
The MainActivity is made to make http request POST to register name,
email and password in my server. Is it possible to start the
SecondActivity whenever he logged in? It's just like Instagram. But, I
could set a condition to check depends if logged or not change the
setContent(R.layout.main) or setContent(R.layout.second)?
Yes, you could have a LoginActivity that is called with startActivityForResult(). It would connect and return the success/failure. (See http://developer.android.com/training/basics/intents/result.html )
Also, keep in mind that HTTP POST is not encrypted, the password is sent as plain text.
When the register is done. All the data is saved on the server. But I
want to check every time he changes activity or do some action if he's
logged in or not. Could I use some thread with a flag(bool)? Could be
a bad practice and reduce the performance? Or SharedPrefrences adding
flag(bool)? But SharedPreferences are saved after the application is
closed?
Yes, SharedPreferences are stored after exiting the application. Ideal to simply implement app settings, but when storing lists of items you should look into other solutions. A JSON file may be of use, you could directly pull/push it from/to server.
About to show my information in every Activity, like name, age and sex
etc and such. Making request http is quite bad for my application,
since it's just TODO app and I don't need to be connected to internet
to see my info, but in case of edit, yes. So I saved in the
SharedPreferences, but stays the same doubt, it will save after I close the application?
See answer above. In short get a JSON string from the server, store it locally in a file. View and edit the local file, then upload it whenever you want. This way it works offline too, but can still download/upload the changes.

Android save login user details in application

I am a web developer and new to android and studying ... For first step I made an user login system using PHP-MySQL web services.
The application communicating with the web service pretty well and check for user exists. Now if the user exists it will return the user details if user exists.
My question is like in web application is there any session / cookie handling in android application ? For eg if I can save the session then not need to login at each and every time.
I am sure there is a way to do this because lots of apps are working with this feature. But since I am new to android please advice a bit.
Not knowing a correct word to googling. Is that "SavePreferences".
Thanks in advance
I think what you are looking for is SharedPreferences. This stores data persistently in a (key, value) pair so you could say have a check box at the login screen so if they check it then it stores a boolean as the value and their username as the key. Then when they get to the login screen and choose their username it checks that value and if it is true then it doesn't require a password. This is assuming that you allow more than one user to login from the app.
However, if you only have one person logging in from the app to that device, then you could send back a value from the web server when they open the app that they can skip the login screen.
Besides the links to the docs I provided above, Here is a good example in the docs to get you started
If you are in need of something more robust than what SharedPreferences provides, then look at the Storage Options section of the docs. Hope this helps
Retrieve prefs
SharedPreferences prefs = this.getSharedPreferences("john smith", 0);
saved= (prefs.getString("loginSaved", false));
if (saved)
// do stuff here
else
// require login
SharedPreferences is what you're looking for!
Check out this code to learn more about how to use it:
http://kettiandroidproject.googlecode.com/svn/trunk/Private/Earthquake/src/com/company/earthquake/Preferences.java

How would I go about creating a login

The set-up:
I have an android application that so far can register a user by inserting values into a remote mysql database. I'm now trying to implement the log in.
I was thinking that I can add a "logged in" column to the user table in the database that would store whether or not the user was logged in. Then I would have a trigger that would log the user off after a certain amount of time has been elapsed.
The application's use is to retrieve files based upon if the user has access to a certain file. For this I have an "access" column in the user table table specifying the access a user has to a certain file. I was thinking that when a user clicks an item in a list the application would send their login information and the server would determine if the information was correct then check to see if they had access to the specified file then send back the file if the information is correct.
The problem I'm having though is that checking the registration information takes about 2 seconds alone(due to connecting to the socket and sending a string over the network) and if I try to check both the login and the access id it would take slightly longer.
I feel as if I'm trying to reinvent the wheel but I can't find any viable resources on this matter. Criticisms? Suggestions?
(I wouldn't mind doing a complete redesign I just need to know where to start)
Never connect a client to a db-server. There's no way to intercept hacking attempts, because privileges are very basic (SELECT, UPDATE, etc., they ignore the query):
UPDATE users SET name='%s' WHERE userID=%i // where %i will be defined as the real userID
Above should be a valid query to update the user's account-information, however, a hacker can easily intercept this and change it into:
UPDATE users SET name='%s' WHERE userID=15 // ... or any other variable
Instead, you should create a web based API which will validate each query, or better, support only specific API-commands:
account/update.json?name=%s

Categories

Resources