ProtocolActivatedEventArgs 类

定义

激活应用时提供数据,因为它是与 URI 方案名称关联的应用。

Javascript 此类型显示为 WebUIProtocolActivatedEventArgs

public ref class ProtocolActivatedEventArgs sealed : IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
public ref class ProtocolActivatedEventArgs sealed : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class ProtocolActivatedEventArgs final : IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class ProtocolActivatedEventArgs final : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ProtocolActivatedEventArgs : IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ProtocolActivatedEventArgs : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
Public NotInheritable Class ProtocolActivatedEventArgs
Implements IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
Public NotInheritable Class ProtocolActivatedEventArgs
Implements IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
继承
Object Platform::Object IInspectable ProtocolActivatedEventArgs
属性
实现

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

OnActivated 事件处理程序接收所有激活事件。 属性指示激活事件的类型。 此示例设置为处理 URI 激活事件。

public partial class App
{
   protected override void OnActivated(IActivatedEventArgs args)
   {
      if (args.Kind == ActivationKind.Protocol)
      {
         ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;

         // TODO: Handle URI activation
         // The received URI is eventArgs.Uri.AbsoluteUri
      }
   }
}
Private Sub OnFileActivated(ByVal args As Windows.ApplicationModel.Activation.IActivatedEventArgs)
   If args.Kind = ActivationKind.Protocol Then
      ProtocolActivatedEventArgs eventArgs = args As ProtocolActivatedEventArgs

      ' TODO: Handle URI activation
      ' The received URI is eventArgs.Uri.AbsoluteUri
   End If
End Sub
void App::OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs const& args)
{
    if (args.Kind() == Windows::ApplicationModel::Activation::ActivationKind::Protocol)
    {
        auto eventArgs{ args.as<Windows::ApplicationModel::Activation::ProtocolActivatedEventArgs>() };

        // TODO: Handle URI activation.
        // The received URI is eventArgs.Uri().RawUri().
    }
}
void App::OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs^ args)
{
   if (args->Kind == Windows::ApplicationModel::Activation::ActivationKind::Protocol)
   {
      Windows::ApplicationModel::Activation::ProtocolActivatedEventArgs^ eventArgs = 
          dynamic_cast<Windows::ApplicationModel::Activation::ProtocolActivatedEventArgs^>(args);

      // TODO: Handle URI activation  
      // The received URI is eventArgs->Uri->RawUri
   } 
}

注解

ActivationKind协议时,实现事件处理程序以响应激活的事件时,将访问此对象。

使用 C++、C# 或 Visual Basic 的 UWP 应用通常通过重写 Application 对象的方法来实现激活点。 默认模板 app.xaml 代码隐藏文件始终包含 OnLaunched 的替代,但为其他激活点(如 OnActivated )定义替代取决于应用代码。 如果 ActivationKindProtocol,则可以将 OnActivated 中的接口类型 IActivatedEventArgs 强制转换为 ProtocolActivatedEventArgs。

激活方案涉及的所有 应用程序 替代都应在其实现中调用 Window.Activate

版本历史记录

Windows 版本 SDK 版本 已添加值
1607 14393 User

属性

CallerPackageFamilyName

获取激活当前应用程序的应用程序的包系列名称。

CurrentlyShownApplicationViewId

获取当前显示的应用视图的标识符。

Data

从激活当前应用程序的应用程序接收的数据。

Kind

获取激活类型。

PreviousExecutionState

获取应用在激活前的执行状态。

SplashScreen

获取初始屏幕对象,该对象提供有关从初始屏幕过渡到激活的应用的信息。

Uri

获取为其激活应用的统一资源标识符 (URI) 。

User

获取为其激活应用的用户。

ViewSwitcher

获取可用于设置应用程序的视图的视图切换器对象。

适用于

另请参阅