Phonegap:onDeviceReady覆盖

时间:2016-01-26 18:45:28

标签: javascript android html cordova phonegap-cli

我有一个专为android设计的phonegap项目,并使用cordova。我在这个phonegap项目中种植了一个基于Web的应用程序。这个应用程序有一个html页面,index.html。在此索引文件中,不调用onDeviceReady()函数。但是,这个页面工作正常,只是从mainactivity调用它,并且由于某种原因它不会进入这个功能。 它可能被cordova函数覆盖。 的问题: 如何在index.html文件中使用此功能? 哪个功能覆盖/替换了这个功能?



        function onLoad() {
			document.addEventListener("deviceready", onDeviceReady, false);
		}

		// device APIs are available
		//
		function onDeviceReady() {
			// Register the event listener
			document.addEventListener("backbutton", onBackKeyDown, false);
		}

		// Handle the back button
		//
		function onBackKeyDown(e) {
			e.preventDefault();
			navigator.notification.confirm("×”×?×? ברצונ×? ×?צ×?ת?", onConfirm, "יצי×?×”", "יצי×?×”,ביטו×?"); 
		}
		function onConfirm(button) {
			if(button==2){//If User selected No, then we just do nothing
				return;
			}else{
				navigator.app.exitApp();// Otherwise we quit the app.
			}
		}




这里发生的是onLoad被调用,而onDeviceReady 从未被调用。

1 个答案:

答案 0 :(得分:0)

对于正在调用的onDeviceReady函数,您必须导入Cordova.js文件。

检查此问题可能会对您有所帮助。

Where do I find cordova.js?

相关问题