Announcement Announcement Module
Collapse
No announcement yet.
Correct way to receive a binary file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Correct way to receive a binary file

    I'm looking for an example of the correct way to receive a binary file with AndroidSpring (with RoboSpice). I put together the following, but I'm getting errors that indicate InputStream isn't the right parameterization. The error complains that there is no message converter to convert to InputStream from text/plain. The file is a binary sqlite database, so I'm also not clear why Spring thinks it is test/plain. What do I change to make this work? Thanks!!!!


    class PlantListRequestListener implements RequestListener< InputStream > {
    @Override
    public void onRequestFailure( SpiceException e ) {

    showProgress(false);

    Observer.unhandledErrorToast("Error during request: " + e.getMessage(), DownloadProjectAssetsActivity.this);
    e.printStackTrace();


    }

    @Override
    public void onRequestSuccess( InputStream response ) {
    FileOutputStream fos;
    try {
    fos = getBaseContext().openFileOutput( project.id+".plantlist.sqlite" , Context.MODE_PRIVATE);
    byte[] buffer = new byte[1024];
    int len1 = 0;
    while ((len1 = response.read(buffer)) != -1) {
    fos.write(buffer, 0, len1);
    }
    fos.close();
    response.close();
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    }
    }

    spiceManager.execute( Observer.observerAPI.getBinaryFileRequest(project. plantlist), null, DurationInMillis.NEVER, new PlantListRequestListener() );

  • #2
    I don't see how that would be the issue here. My Androids are up to date with their latest firmwares. ICS, Jelly Bean, etc. This seems to have more to do with providing the correct implementation of RequestListener, right?

    Originally posted by Millerwhite
    Probably it is because of the firmware upgrade issues. Just have a look into that direction. It might help.

    Comment


    • #3
      Don't know it is right place or not for commenting but i am new here and want to understand this forum it is for tutorials or what? Please help me

      Comment

      Working...
      X