Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

authentification a un server distant

Featured Replies

Posté(e)

bonjour , je doit me connecter a un server webphsere pour récupérer mes données pour cela je doit d abord m authenfier(j arrive a recuperer à partir d un web service les données accessible sans authentification mais mon problème se pose au niveau d authentification ) . j ai cherché quelque chose sur le net mais toujours sans suces . je vous met mon code voir si j ai pas fait des erreur de code . merci d avance




public class Authentification extends Activity {
/** Called when the activity is first created. */
String response;
final String username = "19851985";
String result;
final String password = "android85";

HttpResponse httpresponse;
InputStream chaine;

final String proxyHost = "localhost";
final int proxyPort = 80;

String url = "http://10.0.2.2/webapp/wcs/stores/servlet/AddressBookForm?storeId=10101&catalogId=10101&langId=-2";

HttpEntity entity;
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	DefaultHttpClient client = new DefaultHttpClient();
	AuthScope authScope = new AuthScope(null,-1, AuthScope.ANY_REALM);
	Credentials credential = new UsernamePasswordCredentials(username, password);      
	client.getCredentialsProvider().setCredentials(authScope, credential); 

	HttpGet httpGet = new HttpGet(url);
	httpGet.addHeader("User-Agent", "Android");
	HttpConnectionParams.setConnectionTimeout(client.getParams(), 15000);

		httpresponse = client.execute(httpGet);
	entity = httpresponse.getEntity();
		chaine = entity.getContent();
		result = stream2String(chaine);


	JSONArray jsonOrdArray =  new JSONArray(result);;


	for (int i = 0; i < jsonOrdArray.length(); i++) {
		Order order = new Order();
		JSONObject commande =  jsonOrdArray.getJSONObject(i);;


			order.reference = commande.getString("reference");

	}



}

private String stream2String(InputStream stream)
		throws UnsupportedEncodingException {
	String charSet = "iso-8859-1";
	InputStreamReader reader = new InputStreamReader(stream, charSet);

	BufferedReader buffer = new BufferedReader(reader);
	StringBuilder sb = new StringBuilder();
	try {
		String cur;
		while ((cur = buffer.readLine()) != null) {
			sb.append(cur);
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
	try {
		stream.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return sb.toString();
}

}

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.