Server Selection in Activity - android

I am trying to figure out how to design a page/activity where user will select the server at start of application.For ex. I have 2 servers, if he selects first server I call a certain url and if he selects 2nd server I call a different url throughout the application.Shall I go with listview, spinner or is there some library out there to help me with such design?
Worth to note, the 2 server include country flag next to them.

Related

How to create a single Log In Activity page for two different types of user?

I am a beginner in Android Development (using Java). I am trying to built an App with a single Login Activity Page where there are two types of users - 1. Normal User 2.An Admin . So depending on the user I want the Login Button to redirect them to their respective activity pages.
I have found 2 ways -
By getting the input text from the Username edit text field in login page and using if else condition .
Doing via querying the Database(MySQL & php)
Which of them would be a better choice ? And can anyone provide a code snippet for it ?
According to me best way would be to add a user type in the user info table on the basis of which you can identify the user type on login form just by the response from the database
Working code
It would be better to add RadioGroup for both Normal User and Admin as User can be Admin or Normal.
You can add RadioGroup with 2 Radio Buttons, so user can choose among them,
This Way is better because you dont have to put extra load on your sever for Iterating among both.
Even better would be having different Tables for Normal users and Admin for quick responses.
You can follow this Medium Tutorial for Radio Buttons
Android: Selection Controls

Android Pagination on server or client side

I'm developing an android app, which will fetch data from my webservice and display it to user. I have a confusion in deciding where to keep pagination(in client side or server side)
My scenario is, I ll take input from the user and make a call to my webservice, to fetch all the data available for the input(response is in Json format) and then, display the data fetched in Recyclerview. I want to display only 50 records initially, then when "show more" button is clicked, the next 50 is displayed.
My data(reponse from webservice) range varies from 0 to 15000 , based on the input from user. And I have other filtering parameters in UI, which will change the rendered data when selected.
So, is it good to fetch all the 15000 records at once and do all kind of processing in client side?
or to fetch 50 records each time when "show more" button is clicked? and to fire new API call whenever filter is changed?
Thanks.
You should never try to fetch such a large number of records in one go, because : 1) your app would have a very slow FRT (First Response Time) 2) the user is unlikely to view more than a couple hundred records at any given time. 3) If the user data (2G/3G/4G) is paid, the user ends up paying for data that he would never see.
So, you should always have pagination on the server side and then your client can request subsequent records as and when needed.
Having said that, network requests would take time and waiting for response every time user clicks on "Show More" would be bad UX as well. So, you need to consider batching requests together and even pre-fetching some data. Here is a nice video for you to see before changing your architecture : https://www.youtube.com/watch?v=3kOx-IPqtqA

How to maintain data or show stored data in app until recieve response from server?

I need functionality like facebook app in my app.
the functionality is that when i login in facebook app then feed data load first time and if i click another tab ,like notification tab then load notification list in facebook.
but if i click again feed tab then all feed data showing instantly ,it's maintain cache or database and it's perform like and share functionality.
in my app when i click home tab then loader visible to fetch data from server and click to another tab then fetch data from server.
the question is that i dont want to load every time loader in my app,it's should be first time in every tab, if data addded in my appp from server then i call webservice.
Thanks in Advance.
Forgive me if any type of grammatical mistake.
Well I am not going to help you with code. that's your part. What I can do is give you some idea how to do that.
--> When the application first launches.
What you can do is fetch the data the first time you load app and store it in your SQLlite DB. the relations should match the server side but you can store data how ever suites you best.
--> when you switch tabs.
Save the state of the previous tab this question might help.
--> when you switch to a tab
trigger a run in background or Async Task or a thread to retrieve data from serve and store it in the same local DB. and bind the views to that data for example if you are updating a list calling notifyDataSetChanged() will actually update that list on the screen.
Thats it. Hope that helps.

Android - associate a user to some list item

i'm developing an android application which allows different users to login and see a list of favourite songs.
Each user has its list of songs, and a song is an instance of the corresponding class Song, with some attributes (singer, year, title...). The MainActivity contains the form for the login, so the user has to set its Name and Password. After login, a second activity is started, and it contains the ListView with the user's favourite songs.
How can i associate a single user to its corresponding song's list?
I thinked to use a database to store the songs, but then?
Look at Parse it's very easy to use and let you focus on your android App, instead of spending much time writing and configuring a server-side application.
You need also to implement on your android application a service to handle json ( or xml, it's your choice ). This is an awesome library to handle json JSONP.
Look also to this link for an overview on RESTfulservices.
For example (getting user info):
You need an info on userA.
You format a json with the right info.
Start an http request to your server. It will answer you with another json containing some info.
Parse this json recieved and use the data in your app.
I hope I made myself clear.

Accessing a web service from an android phone

Hello I am new to Android .I have been given an Android project to do. As a part of my project I need to do the following :
1)Create an Android application that takes 3 inputs from user via EditText namely id,address and contact no, and has a submit button at the end to send that data
2)After clicking the submit button , a web service that we will create using Netbeans should get invoked and display it's contents on the phone to the user
The web service will basically contain some predefined data entries that I want to display it to the user with a checkbox
say eg. xyz
yax
where 'xyz' and 'yax' are contents of my web service. The user selects any checkbox say 'xyz' , clicks another submit button below and the entire data namely id , address ,contact no , and now 'xyz' goes into a mysql database.
3) After reading this I am now aware of how to create a web service but the problem I have is how to invoke that web service from an android phone ???
Can someone please help me ?
You can directly use web-service from URL.

Categories

Resources