【发布时间】:2013-06-02 14:05:20
【问题描述】:
我尝试通过手动启动 Google 驱动器(安装在设备上)从我的 android 应用程序上传文件。我尝试使用Intent.createChooser 发送它,它可以正常上传文件附件。但我需要上传特定意图的文件(如 Dropbox,仅限 Google 驱动器)。所以我更改了代码并尝试通过以下方式将文件上传到谷歌驱动器,但没有成功,只有谷歌驱动器应用程序在设备上打开,没有文件上传:
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);
我们可以像上面那样手动打开 Intent 来上传 PDF 文件吗?
【问题讨论】:
标签: android-intent google-drive-api