I tried to download the file from my Android application by manually launching the Google drive (installed on the device). I tried this to send using Intent.createChooserand its operability to download file attachments. But I need to upload the file for a specific purpose (e.g. Dropbox, Google only). Therefore, I changed the code and tried to upload the file to the Google drive as follows, but did not succeed, only the Google Drive application was open on the device, the file was not uploaded:
PackageManager pm = this.getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.google.android.apps.docs");
intent.setType("application/pdf");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://sdcard/sdcard0/test.pdf"));
intent.putExtra(Intent.EXTRA_SUBJECT, "attach a file test");
intent.addCategory(Intent.ACTION_ATTACH_DATA);
startActivity(intent);
Is it possible to download a PDF file by opening the intent manually as above?
source
share