Back to project page spring-for-android-starter-book.
The source code is released under:
Apache License
If you think the Android project spring-for-android-starter-book listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.dahanne.spring.android.ch3.restful.example.recipeapp; //from w w w . j av a 2s.c o m import java.util.ArrayList; import java.util.List; import org.springframework.http.HttpAuthentication; import org.springframework.http.HttpBasicAuthentication; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.web.client.RestClientException; import android.os.AsyncTask; public abstract class RecipeAbstractAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> { private static final String USERNAME = "s4a"; private static final String PASSWORD = "s4a"; protected RestClientException exception; protected HttpHeaders prepareHeadersWithMediaTypeAndBasicAuthentication() { HttpHeaders requestHeaders = new HttpHeaders(); List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>(); acceptableMediaTypes.add(MediaType.APPLICATION_JSON); requestHeaders.setAccept(acceptableMediaTypes); HttpAuthentication authHeader = new HttpBasicAuthentication(USERNAME, PASSWORD); requestHeaders.setAuthorization(authHeader); return requestHeaders; } }