Search This Blog

Sunday, 10 June 2012

converting InputStream to string

We are very much aware about InputStream. InputStream is to  read to content from file or URL. If we handle file then we used FileInputStream and while reading from a URL, we used InputStream.


InputStream is a readable source of bytes. Once you get an InputStream it's common to decode or convert it into a target data type. For example, if you were downloading image data, you might decode and display it directly Read this post to know how to convert input stream to bitmap See How to convert InputStream to bitmap. But if we want to convert InputStream to string then we need to read it line by line like given code


// Reads an InputStream and converts it to a String.
  public static String convertStreamToString(InputStream is) throws Exception {
 BufferedReader reader = new BufferedReader(new InputStreamReader(is));
 StringBuilder sb = new StringBuilder();
 String line = null;
 while ((line = reader.readLine()) != null) {
     sb.append(line);
  }
       is.close();
 return sb.toString();
 }


Challenges against an android application developer

Starting android development is easy thing. Normally developer are fully aware about java language. It makes easy to learn and develop android application. Because of its open source nature so many tutorial are available on internet. after so many thing android development is pain for developer in comparison  of iPhone development in some cases

1) Device resolution and densities : In android thousand of android device available with different kind of densities and resolution. 



ldpimdpihdpixhdpi
small2.3%2.4%
normal0.7%26.2%57.8%0.9%
large0.3%2%
xlarge7.4%









see this picture. A developer can imagine the pain to make one application that runs perfectly in all. That's impossible.But if you see iPhone, its has only two densities iPhone or iPod And iPad


2)Its hard to earn with android : on Google play, there are so many of crap application are present.In iPhone, quality of application are much more better than android. Because of manner of uploading in android, its easy to upload application. I have seen android hello world application on Google market. that make hard to get notice




Android News and source code