Closed GoogleCodeExporter closed 9 years ago
Seems like the file need to be placed in SDCard or other apps can't access it.
Try below to create a temp file with a better file name. Planning to add a
function to do this in the future.
private static final int SEND_REQUEST = 12;
private File tempfile;
public void image_send() throws IOException{
String url = "http://www.vikispot.com/z/images/vikispot/android-w.png";
File cached = aq.getCachedFile(url);
File ext = Environment.getExternalStorageDirectory();
File tempDir = new File(ext, "myapp");
tempDir.mkdirs();
File file = new File(tempDir, "hello.png");
file.createNewFile();
FileInputStream fis = new FileInputStream(cached);
FileOutputStream fos = new FileOutputStream(file);
AQUtility.copy(fis, fos);
fis.close();
fos.close();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivityForResult(Intent.createChooser(intent, "Share via:"), SEND_REQUEST);
tempfile = file;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if(tempfile != null){
tempfile.delete();
tempfile = null;
}
}
Original comment by tinyeeliu@gmail.com
on 1 Oct 2011 at 3:10
Original comment by tinyeeliu@gmail.com
on 3 Oct 2011 at 11:34
Original issue reported on code.google.com by
tinyeeliu@gmail.com
on 1 Oct 2011 at 1:46