Ich versuche, PhoneGap zum ersten Mal auf Android-Gerät (Samsung Galaxy S II) zu laufen; Es scheint jedoch nicht zu funktionieren.PhoneGap nicht in Android
Hier ist der Code, den ich versuchen, so weit:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"
/>
<title>Hello World</title>
<script type="text/javascript" src="cordova-2.2.0.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var options = new ContactFindOptions();
options.filter = "";
options.multiple = true;
var filter = ["displayName"];
navigator.contacts.find(filter, onSuccess, onError, options);
}
function onSuccess(contacts) {
for(var i = 0; i < contacts.length; ++i) {
alert(contacts[i].displayName);
}
alert("OK then");
console.log("OK");
}
function onError(contactError) {
alert("onError!");
console.log("Fail");
}
</script>
</head>
<body >
</body>
<h1> Example </h1>
<p> Find Contacts </p>
</html>
Nichts Show-ups! Keine Warnung, kein Protokoll, es wird nur eine HTML-Seite mit dem Inhalt body
angezeigt.
@Edit: Ergebnisse werden jetzt angezeigt; Alle Ergebnisse sind jedoch null
, die auf Alert
Dialog angezeigt werden. Hat jemand das erlebt?
was ist Ihre 'contacts.length'? –
@PratikSharma: Anzahl der Kontakte gefunden. Mein Handy hat '693', aber alle' displayName' sind 'null'. Es sollte nicht "null" lauten: http://docs.phonegap.com/en/2.2.0/cordova_contacts_contacts.md.html#Contact –
können Sie versuchen, dies in alert 'contacts [i] .name zu setzen .givenName' und es ist immer noch Null? –