Phonegap android项目在模拟器上工作而不在实际的电话上 [英] Phonegap android project works on emulator not on actual phone

查看:101
本文介绍了Phonegap android项目在模拟器上工作而不在实际的电话上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行最新版本的android及其SDK,并且正在使用phonegap创建移动应用程序.我的问题是我正在请求Web服务,并且正在html的标记中显示接收到的消息的内容. Web服务运行良好,显示功能运行良好,甚至可以在模拟器上运行而没有任何错误.当我尝试在真正的android设备上运行相同的应用程序和代码时,就会出现问题.什么都没有发生.我正在测试的设备具有android版本2.3.1和4.0.我用来测试的模拟器是2.2,而android项目是使用android sdk 2.2版创建的.为了确保该问题与android OS版本无关,我还使用4.0版创建了一个测试项目,并在具有相同OS版本的android设备上对其进行了测试,并且遇到了同样的问题.

I'm running the latest version of android and it's SDK and I'm using phonegap to create a mobile application. My problem is that I am requesting a web service and I am displaying the contents of the received message in a tag in my html. The web service is working fine, the displaying feature is working fine, and it's even running on the emulator without any bugs. The problem arises when I try to run the same application and code on a real android device.... nothing happens. The devices I am testing on have android version 2.3.1 and 4.0. The emulator that Im using to test on is 2.2 and the android project was created with android sdk version 2.2. To make sure the issue was unrelated to android OS version, I also created a test project using version 4.0 and tested it on the android device having the same OS version and I get the same problem.

这是我的代码的片段.

 var xhr = new XMLHttpRequest();
            xhr.open("GET", "http://feeds.delicious.com/v2/json/popular", false);
            xhr.send(null);
            if (xhr.readyState==4 && xhr.status==200){

                clearLoadingScreen();

                var popular= $("#disclaimer").html("");
                popular= "";

                $("#popular").append('<div class="popular"><p>Popular:</p>'+ "This is an example popular list<br />" + popular+ ' </div>'); 
           }

像我说的那样,

该代码在模拟器上可以正常工作,当index.html页面加载时,我看到一个空白屏幕,几秒钟后,它被填充.当我将代码移植到手机上时,它不起作用.有谁知道为什么吗?

like I said, the code works perfectly on the emulator, when the index.html page loads, I see a blank screen and a few seconds later the is populated. When I port the code to the phone, it does not work. Does anyone have any ideas why?

推荐答案

检查位于以下位置的策略: project/res/xml/cordova.xml(如果使用Cordova-为phonegap 1.6或更高版本)

Check your policy located in: project/res/xml/cordova.xml (if using Cordova - which is phonegap 1.6? or higher)

如果是较低版本,则称为phonegap.xml.

It's called phonegap.xml if on a lower version.

这篇关于Phonegap android项目在模拟器上工作而不在实际的电话上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆