【问题标题】:Send file to an app for further processing将文件发送到应用程序以进行进一步处理
【发布时间】:2014-02-10 06:58:10
【问题描述】:

对于某些文件(例如图像),可以按“共享”按钮。然后会打开一个可用于共享此文件的应用程序列表。 When one of these applications is chosen, the file (or pathname?) is handed over to this app for further processing.

我的问题是:这是如何实现的?如何注册我的应用程序以针对某些特定文件类型列出?该应用如何接收必须与该应用共享文件的信息?

谢谢!

【问题讨论】:

标签: android data-transfer


【解决方案1】:

共享适用于特定的意图过滤器操作ACTION_SEND

任何想要注册特定类型数据的应用都可以在其清单文件中声明适当的意图过滤器。

另一方面,想要触发共享操作的应用程序需要以适当的意图启动 Activity,如下所述:http://developer.android.com/training/sharing/send.html#send-binary-content

例如分享图片:

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/jpeg");
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));

【讨论】:

    猜你喜欢
    • 2012-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-31
    • 2018-06-02
    • 1970-01-01
    • 1970-01-01
    • 2021-11-09
    相关资源
    最近更新 更多