Windows Phone 8 PhoneGap 앱을 개발 중입니다. navigator.app.exitApp() 사용 Windows Phone 7의 홈 화면에서 앱을 종료합니다.하지만 Windows Phone 8에서 동일한 시도를하면 Unable to get property 'exitApp' of undefined or null reference
오류가 발생합니다. Windows Phone 7 PhoneGap 앱이 아닌 Windows Phone 8에서 정의되지 않은 이유를 알고 싶습니다. 또한, 알고 싶습니다, Windows 전화 8 PhoneGap 응용 프로그램에서 프로그래밍 방식으로 응용 프로그램을 종료하는 방법이 있습니까?. 여기navigator.app.exitApp()가 작동하지 않습니다.
답변
비슷한 질문 : https://groups.google.com/forum/#!msg/phonegap/9v2kOwXj6sQ/O8SVpd-qjicJ
그러나 기본적으로 윈도우 폰 8 앱 프로그래밍 방식으로 종료되지 않아야 함을 말한다.
Navigator.app.exit()
응용 프로그램을 종료하지 않으면 응용 프로그램이 중단됩니다.
Windows Phone 8에서는 예외가 발생하므로 처리됩니다.
당신은 하드웨어 BACK 버튼을 눌러에서 응용 프로그램을 종료합니다
Application.Current.Terminate();
CordovaView.xaml.cs
에 page_BackKeyPress 이벤트에 아래의 코드를 작성해야합니다.
Navigator.app.exit() WP8 Cordova 3+ –
간단한 플러그인을 만들 수 있습니다.
using System.Windows;
namespace WPCordovaClassLib.Cordova.Commands
{
class ExitApp : BaseCommand
{
public void execute(string options)
{
Application.Current.Terminate();
}
}
}
편집하여 플랫폼/WP8/config.xml 파일을 위젯 태그에 추가 : 당신의 플랫폼/WP8/플러그인 폴더에 파일 ExitApp.css 추가에서 다음
<feature name="ExitApp">
<param name="wp-package" value="ExitApp" />
</feature>`
자바 스크립트 호출
: 사용자가 메인 페이지에서 BACK 버튼을 클릭 할 때cordova.exec(null, null, "ExitApp", "execute", []);
당신은 응용 프로그램을 닫습니다 BACK 버튼 이벤트와 함께 사용할 수 있습니다
function goBack(e){
if(isInMyMainPage()) cordova.exec(null, null, "ExitApp", "execute", []);
}
document.addEventListener("backbutton", goBack, false)
에 정의되지 않은 이유는 무엇입니까? 프로덕션에서 사용하고 있습니다. – TlmaK0
유용 !! 그것의 일 .... 고맙습니다 !!! – BlackPOP
고마워요 ... 그 일이 – ConnectingCode
여기 비슷한 질문 : How to exit an application in window phone 8 with phonegap 2.3에는 기본 해킹이 필요하지 않은 수정 프로그램이 포함되어 있습니다.
버전 3.6.3에서 navigator.app.exitApp()가 작동합니다. 여기
은)는 (CordovaView.cs
void CordovaBrowser_ScriptNotify(object sender, NotifyEventArgs e)
{
string commandStr = e.Value;
string commandName = commandStr.Split('/').FirstOrDefault();
if (browserDecorators.ContainsKey(commandName))
{
browserDecorators[commandName].HandleCommand(commandStr);
return;
}
CordovaCommandCall commandCallParams = CordovaCommandCall.Parse(commandStr);
if (commandCallParams == null)
{
// ERROR
Debug.WriteLine("ScriptNotify :: " + commandStr);
}
else if (commandCallParams.Service == "CoreEvents")
{
switch (commandCallParams.Action.ToLower())
{
case "overridebackbutton":
string arg0 = JsonHelper.Deserialize<string[]>(commandCallParams.Args)[0];
this.OverrideBackButton = (arg0 != null && arg0.Length > 0 && arg0.ToLower() == "true");
break;
case "__exitapp":
Debug.WriteLine("Received exitApp command from javascript, app will now exit.");
CordovaBrowser.InvokeScript("eval", new string[] { "cordova.fireDocumentEvent('pause');" });
CordovaBrowser.InvokeScript("eval", new string[] { "setTimeout(function(){ cordova.fireDocumentEvent('exit'); cordova.exec(null,null,'CoreEvents','__finalexit',[]); },0);" });
break;
case "__finalexit":
IsExiting = true;
// hide the browser to prevent white flashes, since about:blank seems to always be white
CordovaBrowser.Opacity = 0d;
CordovaBrowser.Navigate(new Uri("about:blank", UriKind.Absolute));
break;
}
}
else
{
if (configHandler.IsPluginAllowed(commandCallParams.Service))
{
commandCallParams.Namespace = configHandler.GetNamespaceForCommand(commandCallParams.Service);
nativeExecution.ProcessCommand(commandCallParams);
}
else
{
Debug.WriteLine("Error::Plugin not allowed in config.xml. " + commandCallParams.Service);
}
}
}
navigator.app.exitApp에서 호출되는 경우; 나는 윈도우 폰 8.1 아래의 코드에 대한 작은 응용 프로그램을 개발 3.4.0
<div onclick="navigator.app.exitApp()">Exodus</div>
이후 아파치 코르도바 WP8 프로젝트에 사용할 수있다하는 것은 나를 위해 작동 :
window.close();
멋지다! Windows 10 Apps에서 작동합니다. – SergiP
- 1. AlarmManager가 작동하지 않습니다. 서비스가 작동하지 않습니다.
- 2. URL 리디렉션이 작동하지 않습니다 .htaccess가 작동하지 않습니다.
- 3. XMapWindow가 작동하지 않습니다. XMapWindow가 작동하지 않습니다.
- 4. . 크롬에서 작동하지 않습니다. 크롬에서 작동하지 않습니다.
- 5. Laravel 컨트롤러가 작동하지 않습니다. 작동하지 않습니다.
- 6. 작동하지 않습니다
- 7. 작동하지 않습니다?
- 8. . 작동하지 않습니다.
- 9. 변환기가 작동하지 않거나 작동하지 않습니다.
- 10. .htaccess가 작동하지 않거나 작동하지 않습니다.
- 11. 카메라가 작동하지 않지만 작동하지 않습니다.
- 12. 패브릭 '작동하지 않음'이 작동하지 않습니다.
- 13. HtmlAgilityPackSanitizerProvider가 작동하지 않습니다. 올바르지 않습니다.
- 14. ItemClickListener가 작동하지 않습니다. 탐색 서랍 목록 항목을 클릭하면 작동하지 않습니다.
- 15. Backbone.Undo.js가 원하는대로 작동하지 않습니다. 사실 전혀 작동하지 않습니다.
- 16. Vim 키 매핑이 제대로 작동하지 않습니다. Ctrl 키가 작동하지 않습니다.
- 17. Ksoap2 보낸 데이터가 작동하지 않습니다. "request.addProperty ("Lat ","21233232 ");" 작동하지 않습니다
- 18. 공용 함수에서 이중화 키 업데이트가 작동하지 않습니다. PHP가 작동하지 않습니다.
- 19. Python이 올바르게 작동하지 않습니다. Linkedin Api가 제대로 작동하지 않습니다.
- 20. Textview에서 공유 데이터가 작동하지 않습니다. 데이터 상태가 작동하지 않습니다.
- 21. HTML 양식이 작동하지 않습니다. Isset POST가 PHP에서 작동하지 않습니다.
- 22. 파이썬 프로그램이 작동하지 않습니다. 입력 == 문자열이 작동하지 않습니다.
- 23. 삽입 트리거가 작동하지 않습니다. 삽입 트리거가 작동하지 않습니다.
- 24. Joverery hover 기능이 작동하지 않습니다. hover out에서 작동하지 않습니다.
- 25. OpenLayers.Filter.Function이 예상대로 작동하지 않습니다. 사실 전혀 작동하지 않습니다.
- 26. 인터넷 검색 기능이 작동하지 않습니다. jQuery가 작동하지 않습니다.
- 27. Brindy Vaadin OSGi/Guessit -Felix가 작동하지 않습니다. Equinox가 작동하지 않습니다.
- 28. 체크 박스 값으로 필터가 작동하지 않습니다. 자바 스크립트가 작동하지 않습니다.
- 29. 뮤텍스 잠금이 작동하지 않습니다. 리눅스 본쉘에서 작동하지 않습니다.
- 30. SVN 전역 무시가 작동하지 않습니다. (다른 게시물의 솔루션이 작동하지 않습니다.)
이 정확하지 않은, 당신이 그것을 할 수 간단한 pluging 만들기, 내 대답을 봐 – TlmaK0