I am trying to send a file from my application on android phone to other devices (they may or may not be be android phones).
my whole code for sending the file is :
try{
File dir = getCacheDir();
File f;
try {
f = File.createTempFile("card", ".Xcard", dir);
Intent i = new Intent();
i.setAction(Intent.ACTION_SEND);
i.setType("*/*");
i.putExtra(i.EXTRA_STREAM, Uri.fromFile(f));
startActivity(i);
} catch (IOException e) {
// TODO Auto-generated catch block
Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}catch(Exception e){
Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_LONG).show();
}
But my file is not being sent to the phone?? What is wrong in the code? Is it because the receiving phone does not recognize my ".Xcard" file?
But I don't think that is the problem because i tried sending "apk" file to the other device and it received even though it doesn't understand the apk file. (i am trying with the non-android phone).
Then why not the file that I am sending being not-sent? is it because it is created in Cache directory?