Reputation: 1367
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?
Upvotes: 0
Views: 95
Reputation: 4115
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.
Upvotes: 2