我想使用共享Intent共享一个文件(.pdf,.apk等),我搜索谷歌但我发现只有共享图像的代码
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(path);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
Run Code Online (Sandbox Code Playgroud)
请帮忙解决这个问题
为了使您的代码务实,请使用ShareCompat类:
ShareCompat.IntentBuilder.from(this)
.setStream(uri)
.setType(URLConnection.guessContentTypeFromName(file.getName()))
.startChooser();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10604 次 |
| 最近记录: |