Android Server Data Fetch
I want to fetch some data from a server protected with an username and password . I know both the username and password . Since the server is live , the data is continuing changing
Solution 1:
You can try this for the post object. Pre-emptive authentication is done this way.
HttpPostpost=newHttpPost(url);
// Prepare the authentication.StringusernameAuth="u";
StringpasswordAuth="p";
post.addHeader("Authorization", "Basic " +
Base64.encodeToString((usernameAuth + ":" + passwordAuth).getBytes("UTF-8"),
android.util.Base64.NO_WRAP));
For running this at regular intervals :
mTimer.scheduleAtFixedRate(newTimerTask() {
@Overridepublicvoidrun() {
// What you want to do goes here
}
}, 0, REFRESH_TIME);
I hope it helps.
Post a Comment for "Android Server Data Fetch"