DocumentsContract.CreateWebLinkIntent(ContentResolver, Uri, Bundle) 方法

定义

创建用于获取指定文档的 Web 链接的意向。

[Android.Runtime.Register("createWebLinkIntent", "(Landroid/content/ContentResolver;Landroid/net/Uri;Landroid/os/Bundle;)Landroid/content/IntentSender;", "", ApiSince=26)]
public static Android.Content.IntentSender? CreateWebLinkIntent (Android.Content.ContentResolver content, Android.Net.Uri uri, Android.OS.Bundle? options);
[<Android.Runtime.Register("createWebLinkIntent", "(Landroid/content/ContentResolver;Landroid/net/Uri;Landroid/os/Bundle;)Landroid/content/IntentSender;", "", ApiSince=26)>]
static member CreateWebLinkIntent : Android.Content.ContentResolver * Android.Net.Uri * Android.OS.Bundle -> Android.Content.IntentSender

参数

content
ContentResolver
uri
Uri

要创建链接的文档的 URI。

options
Bundle

用于生成链接的额外信息。

返回

获取 Web 链接的意向发送方;如果文档不可链接,或创建意向发件人失败,则为 null。

属性

注解

创建用于获取指定文档的 Web 链接的意向。

请注意,由于内部限制,如果已为指定文档创建了 Web 链接意向,但使用不同的选项,则可以重写它。

提供程序需要显示为链接文档授予的所有新权限的确认 UI。

如果收件人列表已知,则应以电子邮件地址列表的形式 Intent#EXTRA_EMAIL 传入选项。 请注意,这只是提供程序的提示,可以忽略列表。 在任一情况下,都需要提供程序显示 UI,以便用户确认任何新的权限授予。

请注意,整个 options 捆绑包将发送到支持传递 uri的提供程序。 在传递任何敏感信息之前,请确保信任提供程序。

由于此 API 可能显示 UI,因此无法从后台调用它。

若要获取 Web 链接,请使用如下所示的代码:

<code>
            void onSomethingHappened() {
              IntentSender sender = DocumentsContract.createWebLinkIntent(<i>...</i>);
              if (sender != null) {
                startIntentSenderForResult(
                    sender,
                    WEB_LINK_REQUEST_CODE,
                    null, 0, 0, 0, null);
              }
            }

<i>(...)</i>

            void onActivityResult(int requestCode, int resultCode, Intent data) {
              if (requestCode == WEB_LINK_REQUEST_CODE && resultCode == RESULT_OK) {
                Uri weblinkUri = data.getData();
<i>...</i>
              }
            }
</code>

适用于 . 的 android.provider.DocumentsContract.createWebLinkIntent(android.content.ContentResolver, android.net.Uri, android.os.Bundle)Java 文档

本页的某些部分是根据 Android 开放源代码项目创建和共享的工作进行的修改,并根据 Creative Commons 2.5 属性许可证中所述的术语使用。

适用于