Using java Syntax Highlighting
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- TextView tv=new TextView(this);
- int response=-1;
- try {
- URL url = new URL("http://<valid_image_url>");
- URLConnection conn = url.openConnection();
- if (!(conn instanceof HttpURLConnection)) throw new IOException("Not an HTTP connection.");
- HttpURLConnection httpConn = (HttpURLConnection) conn;
- httpConn.setAllowUserInteraction(false);
- httpConn.setConnectTimeout(1000);
- httpConn.setReadTimeout(1000);
- httpConn.setInstanceFollowRedirects(true);
- httpConn.setDoOutput(true);
- httpConn.setDoInput(true);
- httpConn.setRequestMethod("POST");
- httpConn.setRequestMethod("GET");
- httpConn.connect();
- response = httpConn.getResponseCode();
- if (response == HttpURLConnection.HTTP_OK) {
- InputStream in = httpConn.getInputStream();
- Bitmap bitmap = BitmapFactory.decodeStream(in);
- tv.setText("HTTP_OK");
- }
- else {
- tv.setText(String.valueOf(response));
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- tv.setText(e.getMessage().toString());
- e.printStackTrace();
- }
- setContentView(tv);
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
I tried to replace the URL with "http://username:passwor@<camera_ip>/jpg/image.jpg" but i have got exception.
thank you for any help



