如何从最近选择任何文件并将其上传到服务器



我想从android应用程序上传文件到服务器上,所以用户可以从android应用程序中选择任何文件,如图像,文档或任何PDF,并将上传到服务器上。

请告诉我如何打开最近的活动,选择任何文件以及如何将其上传到服务器。

请帮我解决这个非常重要的问题。

您可以使用*/*来打开所有文件,就像在android中一样。

Intent intent = new Intent();    
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, getString(R.string.perform_action_with)), attachmentChoice);

注意:在attachmentChoice 常数

最新更新