Code example for HttpRequestBase

Methods: setHeader

0
			} 
		}.executeOnExecutor(EXECUTOR);
	} 
	 
	protected static void addAcceptJSONHeader(HttpRequestBase method) {
		method.setHeader("Accept", "application/json");
	} 
	 
	protected static void addAuthHeader(HttpRequestBase method, Context parent) {
		String loginPref = Preferences.getPreference(parent, Preferences.MY_CHANNEL_JID);
        String passPref = Preferences.getPreference(parent, Preferences.PASSWORD);
        String auth = loginPref.split("@")[0] + ":" + passPref;
		String authToken = Base64.encodeToString(auth.getBytes(), Base64.NO_WRAP);
		method.setHeader("Authorization", "Basic " + authToken);
	} 
	 
	protected static void addUserAgentHeader(HttpRequestBase method, Context parent) {
		try { 
			PackageInfo pInfo = parent.getPackageManager().getPackageInfo(
					parent.getPackageName(), 0);
Contextual code suggestions in your IDE  Get Codota for Java