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 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
   } 
}

注解

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

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

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

版本历史记录

Windows 版本 SDK 版本 增值
1607 14393 User

属性

CallerPackageFamilyName

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

CurrentlyShownApplicationViewId

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

Data

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

Kind

获取激活类型。

PreviousExecutionState

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

SplashScreen

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

Uri

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

User

获取激活应用的用户。

ViewSwitcher

获取允许为应用程序设置视图的视图切换器对象。

适用于

另请参阅