About the history of Android

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

About the history of Android

Postby rock » Mon Jan 21, 2008 10:20 am

Hello, I want to know about how long for google to develop the Android platform, and about the team size.
How does Android access internet(flow, interfaces, classes, libs etc...)?

Thanks!
rock
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jan 21, 2008 10:04 am

Top

Postby faldureon » Fri Jan 25, 2008 3:07 am

Supposedly android was under development for three years before google bought it and gave it to the world. Internet access in android is best done using the HttpClient in combination with GetMethod and PostMethod.
Here is an example of a post and a get from my android challenge contest entry:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         @Override
  3.  
  4.         public boolean uploadShareable(Shareable shareable) {
  5.  
  6.                 boolean retval = false;
  7.  
  8.                 try {
  9.  
  10.                         HttpClient client = new HttpClient();
  11.  
  12.                         // post to the server SERVER_NAME =
  13.  
  14.                         // "http://android-geocast.com/GeocastServer/ShareablePostingServlet";
  15.  
  16.                         PostMethod method = new PostMethod(SERVER_NAME);
  17.  
  18.  
  19.  
  20.                         // add the content(the shareable as a byte array) to the postmethod
  21.  
  22.                         method.setRequestEntity(new ByteArrayRequestEntity(shareable
  23.  
  24.                                         .getBytes()));
  25.  
  26.  
  27.  
  28.                         // do the actual http post
  29.  
  30.                         client.executeMethod(method);
  31.  
  32.  
  33.  
  34.                         // the servlet will return an error code if something goes wrong
  35.  
  36.                         String result = String.valueOf(method.getResponseBody());
  37.  
  38.                         if (result.contains(COMMON_ERROR_RESPONSE)) {
  39.  
  40.                                 retval = false;
  41.  
  42.                         } else {
  43.  
  44.                                 retval = true;
  45.  
  46.                         }
  47.  
  48.                 } catch (Exception e) {
  49.  
  50.                         Log.e("ShareableDaoDbImpl.uploadShareable", e.getMessage());
  51.  
  52.  
  53.  
  54.                         // TODO XXX in the final version network failure should not be fatal
  55.  
  56.                         throw new FatalException("ShareableDaoDbImpl.uploadShareable", e);
  57.  
  58.                 }
  59.  
  60.  
  61.  
  62.                 return retval;
  63.  
  64.         }
  65.  
  66.  
  67.  
  68.         /*
  69.  
  70.          * (non-Javadoc)
  71.  
  72.          *
  73.  
  74.          * @see org.technocore.integration.dao.ShareableDao#getShareableContent(long)
  75.  
  76.          *      shareable content has to go through separately as it is large and
  77.  
  78.          *      may contain the terminating sequence
  79.  
  80.          */
  81.  
  82.         @Override
  83.  
  84.         public byte[] getShareableContent(long shareableId) {
  85.  
  86.                 byte[] retval = null;
  87.  
  88.                 try {
  89.  
  90.                         HttpClient client = new HttpClient();
  91.  
  92.  
  93.  
  94.                         // do a get from the server SERVER_NAME =
  95.  
  96.                         // "http://android-geocast.com/GeocastServer/ShareablePostingServlet";
  97.  
  98.                         GetMethod getMethod = new GetMethod(SERVER_NAME);
  99.  
  100.  
  101.  
  102.                         // add a parameter shareable id to the get, namevaluepair makes
  103.  
  104.                         // url encoding a non issue!
  105.  
  106.                         getMethod.setQueryString(new NameValuePair[] { new NameValuePair(
  107.  
  108.                                         "shareableId", String.valueOf(shareableId)) });
  109.  
  110.  
  111.  
  112.                         // execute the actual http get
  113.  
  114.                         client.executeMethod(getMethod);
  115.  
  116.                         ByteArrayOutputStream bos = new ByteArrayOutputStream();
  117.  
  118.  
  119.  
  120.                         // pull out what the server sent back
  121.  
  122.                         InputStream inputStream = getMethod.getResponseBodyAsStream();
  123.  
  124.                         int temp;
  125.  
  126.                         while ((temp = inputStream.read()) != -1) {
  127.  
  128.                                 bos.write(temp);
  129.  
  130.                         }
  131.  
  132.  
  133.  
  134.                         // the resulting byte array is the content of the shareable
  135.  
  136.                         retval = bos.toByteArray();
  137.  
  138.                 } catch (Exception e) {
  139.  
  140.                         Log.e("ShareableDaoDbImpl.getShareableContent", e.getMessage());
  141.  
  142.                         // TODO XXX in the final version network failure should not be fatal
  143.  
  144.                         throw new FatalException("ShareableDaoDbImpl.getShareableContent",
  145.  
  146.                                         e);
  147.  
  148.                 }
  149.  
  150.  
  151.  
  152.                 return retval;
  153.  
  154.         }
  155.  
  156.  
Parsed in 0.038 seconds, using GeSHi 1.0.8.4
faldureon
Developer
Developer
 
Posts: 27
Joined: Sun Dec 02, 2007 10:19 pm

Top

Return to General

Who is online

Users browsing this forum: No registered users and 4 guests