小编use*_*928的帖子

Android从其他应用程序启动Google云端硬盘应用程序而非上传文件

我尝试通过手动启动Google驱动器(安装在设备上)从我的Android应用程序上传文件.我尝试使用Intent.createChooser它来发送文件附件,并且工作正常.但我需要上传特定意图的文件(例如Dropbox,仅限Google云端硬盘).所以我更改了代码并尝试按以下方式将文件上传到Google云端硬盘,但没有成功,只有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);
Run Code Online (Sandbox Code Playgroud)

我们可以通过手动打开意图上传PDF文件吗?

android-intent google-drive-api

4
推荐指数
1
解决办法
7584
查看次数

标签 统计

android-intent ×1

google-drive-api ×1