jueves, 30 de enero de 2014
Adding % in strings.xml
just add formatted="false" in the entry:
Please the field %s, in %s, should have a value!
Get connectivity in android
Common solution:
ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();Using a broadcast receiver when the network state change:
Post data in body part
try { URL url = new URL("http://requestb.in/14a9s7m1"); HttpURLConnection conn; conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); OutputStream os = null; try { os = conn.getOutputStream(); os.write("fkdlsakl!".getBytes()); } catch (Exception e) { e.printStackTrace(); } os.close(); conn.connect(); int respCode = conn.getResponseCode(); if(respCode == 200) { InputStream ip = conn.getInputStream(); // response.headers = conn.getHeaderFields(); int s = ip.read(); ip.close(); } } catch (Exception e) {}
Suscribirse a:
Entradas (Atom)