Recall 는 애플리케이션의 스냅샷을 자동으로 저장합니다. 그러나 스냅샷 시 UserActivity 를 제공하지 않는 한 사용자는 콘텐츠로 다시 실행할 수 없습니다. 이렇게 하면 Recall이 사용자를 그 당시 보고 있던 내용으로 돌아가게 할 수 있습니다.
UserActivity는 사용자가 앱 내에서 작업하고 있던 특정 항목을 나타냅니다. 예를 들어 사용자가 문서를 작성할 때 사용자가 UserActivity 쓰기를 중단한 문서의 특정 위치를 참조할 수 있습니다. 음악 앱을 UserActivity 들을 때 사용자가 마지막으로 수신한 재생 목록이 될 수 있습니다. 캔버스 UserActivity 에 그릴 때 사용자가 마지막으로 표시한 위치일 수 있습니다. 요약하자면, 사용자가 UserActivity 작업을 다시 시작할 수 있도록 사용자가 돌아갈 수 있는 Windows 앱 내의 대상을 나타냅니다.
사용자 활동 전송
앱의 기본 콘텐츠가 변경(예: 다른 전자 메일 열기, 다른 웹 페이지 열기 등)할 때마다 시스템에서 현재 열려 있는 콘텐츠를 알 수 있도록 앱이 새 UserActivitySession 콘텐츠를 기록해야 합니다.
Recall 는 저장한 스냅샷과 가장 최근 UserActivity 항목을 연결하고 ActivationUri 활동 내에서 사용자가 해당 콘텐츠로 다시 시작하도록 허용합니다.
실행 Recall되지 않는 PC에서도 모든 PC에서 사용자 활동을 푸시하는 것이 좋습니다.
UserActivitySession _previousSession;
private async Task OnContentChangedAsync()
{
// Dispose of any previous session (which automatically logs the end of the interaction with that content)
_previousSession?.Dispose();
// Generate an identifier that uniquely maps to your new content.
string id = "doc135.txt";
// Create a new user activity that represents your new content
var activity = await UserActivityChannel.GetDefault().GetOrCreateUserActivityAsync(id);
// Populate the required properties
activity.DisplayText = "doc135.txt";
activity.ActivationUri = new Uri("my-app://docs/doc135.txt");
// Save the activity
await activity.SaveAsync();
// And start a new session tracking the engagement with this new activity
_previousSession = activity.CreateSession();
}
비고
GetOrCreateUserActivityAsync 메서드는 항상 최신 버전의 Windows에서 새 작업을 반환합니다. 이전에 저장된 활동을 가져오는 기능이 제거되었으며 Windows는 앱에서 검색할 수 있는 방식으로 앱의 이전 활동을 더 이상 저장하지 않습니다.
선택 사항: 요청된 이벤트 처리
푸시 활동 외에도 앱에서 이벤트를 구현 UserActivityRequested 하도록 선택할 수 있습니다. 이 이벤트는 Windows에서 실행되어 앱의 최신 활동이 있는지 확인할 수 있습니다.
public void OnLaunched()
{
UserActivityRequestManager.GetForCurrentView().UserActivityRequested += UserActivityRequested;
}
private async void UserActivityRequested(
Windows.ApplicationModel.UserActivities.UserActivityRequestManager sender,
Windows.ApplicationModel.UserActivities.UserActivityRequestedEventArgs args)
{
// Start a deferral so you can use async code
var deferral = args.GetDeferral();
try
{
// Generate an identifier that uniquely maps to your current content.
string id = "doc135.txt";
// Create a user activity that represents your current content
var activity = await UserActivityChannel.GetDefault().GetOrCreateUserActivityAsync(id);
// Populate the required properties
activity.DisplayText = "doc135.txt";
activity.ActivationUri = new Uri("my-app://docs/doc135.txt");
// And return the activity to the event handler
args.Request.SetUserActivity(activity);
}
finally
{
// And complete the deferral
deferral.Complete();
}
}
관련 콘텐츠
- UserActivity 클래스
-
UserActivity ContentInfo에 Recall 민감도 레이블 제공 - 엔터프라이즈 DLP 정책 적용을 통해 민감도 레이블 메타데이터를
UserActivity.ContentInfo제공하는 방법 알아보기 - 웹 브라우저 개발자를 위한 지침
Windows developer