내 응용 프로그램은 보조 타일을 고정하여 응용 프로그램을 시작하는 데 사용할 수 있습니다. 내가 달성하기 위해 노력하고 행동은 이것이다 : -Windows Phone 8.1 - Exit() 메서드가 작동하지 않습니다.
- 응용 프로그램이 이미 보조 타일을 클릭하면 실행중인 경우, 그것은 URI를 시작 앱이 때 실행되지 않은 경우
- 를 실행하는 응용 프로그램을 잎 보조 타일을 클릭하면 URI를 시작한 다음 Exit() 메소드를 호출하여 앱을 종료합니다 (사용자가 앱 전환보기에 추가 앱을 표시하지 않도록).
아래와 같이 app.xaml.cs의 OnLaunched()에서이 작업을 수행하는 데 사용하는 코드입니다.
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
// Check to see if app has been launched from a secondary tile
if (e.Kind==ActivationKind.Launch && e.TileId != "App")
{
//If so then launch Uri passed from tile
var uri = new Uri(e.Arguments);
Windows.System.Launcher.LaunchUriAsync(uri);
//If launched from a secondary tile, then close the app if it wasn't already running
if (e.PreviousExecutionState == ApplicationExecutionState.NotRunning)
{
Exit();
}
}
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
// TODO: change this value to a cache size that is appropriate for your application
rootFrame.CacheSize = 1;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// Removes the turnstile navigation for startup.
if (rootFrame.ContentTransitions != null)
{
this.transitions = new TransitionCollection();
foreach (var c in rootFrame.ContentTransitions)
{
this.transitions.Add(c);
}
}
rootFrame.ContentTransitions = null;
rootFrame.Navigated += this.RootFrame_FirstNavigated;
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (!rootFrame.Navigate(typeof(SignInPage), e.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
// Ensure the current window is active
Window.Current.Activate();
}
에뮬레이터에서 실행할 때 필요에 따라 정확하게 작동합니다. 그러나 내 장치 (Nokia 925)에서 실행하면 보조 타일에서 실행될 때 앱이 종료되지 않으므로 이전에 실행되지 않았더라도 항상 앱 전환 창이 나타납니다.
EDIT OnLaunched()에서 Exit() 메서드를 호출하면 올바르게 종료되고 올바르게 종료됩니다. 난 단지가 있다고 가정 할 수있는 응용 프로그램이 그 작동하지 않는 실행되고, 따라서 종료()를 호출되어 있는지 여부를 확인 '경우'
if (e.PreviousExecutionState == ApplicationExecutionState.NotRunning)
무슨 일이 일어나고 있는지 모든 아이디어를 어떻게 얻을 수있는 에뮬레이터처럼 행동하는 전화?
Lumia 1520에서 실행중인 응용 프로그램의 OnLaunched 이벤트 처리기에서 Exit() 메서드를 호출하고 응용 프로그램이 종료되었습니다. –
방금 Exit() 메서드를 호출 해봤는데 작동했습니다. 그것처럼 보인다 if (e.PreviousExecutionState == ApplicationExecutionState.NotRunning) 그때 작동하지 않는 논리 .... 이상. – smb1973
내 의견이 도움이 되었기 때문에 기쁩니다. –