private File downloadMemberPhoto(Host profileInfo, String targetFilePath) { File targetFile = new File(targetFilePath); if (targetFile.exists()) { targetFile.delete(); } HttpURLConnection c = null; FileOutputStream fos = null; BufferedOutputStream out = null; try { c = (HttpURLConnection) new URL(profileInfo.getProfilePictureLarge()).openConnection(); fos = new FileOutputStream(targetFilePath); out = new BufferedOutputStream(fos); InputStream in = c.getInputStream(); byte[] buffer = new byte[16384]; int len = 0; while ((len = in.read(buffer)) > 0) { fos.write(buffer, 0, len); } fos.flush(); } catch (Exception e) { Log.i(TAG, "Error: " + e); } finally { try { fos.getFD().sync(); out.close(); c.disconnect(); } catch (Exception e) { // Don't worry about these? } } return targetFile; }
@Override public void onClusterItemInfoWindowClick(HostBriefInfo host) { Intent i = new Intent(this, HostInformationActivity.class); i.putExtra("host", Host.createFromBriefInfo(host)); i.putExtra("id", host.getId()); startActivityForResult(i, 0); }