I have the following code to share a file via Intent.ACTION_SEND. The last line shows a chooser so that the user can pick an appropriate app. When I chose the email everything is fine and the file is attached to the email. On the other hand, when I pick Google drive the file is uploaded to the google drive but the name of the file is changed to "backup" which is the subject. That is, if I call shareBackup("/sdcard/001.mks")
then the file name on the Google drive is "Backup" not "001.mks". Is there any problem with my code?
public void shareBackup(String path) {
String to = "YourEmail@somewhere.com";
String subject = "Backup";
String message = "Your backup is attached";
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
File f = new File(path);
email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
email.setType("text/*");
startActivity(Intent.createChooser(email, "Send"));
}