Meaningless Drivel is fun!*
The moose likes Android and the fly likes json and phonegap (cordova) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "json and phonegap (cordova)" Watch "json and phonegap (cordova)" New topic
Author

json and phonegap (cordova)

Lou Emmelot
Greenhorn

Joined: May 14, 2012
Posts: 3
Hello Damon/Sebastien,
I'am new in Java/Javascript but I learned a lot reading and probing your book 'Pro Android Web Apps'. Just What I needed.
Hoping to produce a webapp on the base of your TODOLIST I had it working in my browser as well in my android as a web page.
So I tried to make a real native .apk with the Phonegap framework in Eclipse. That also worked with the exception that the json database does not respond.
I can see that something is happening in Googles appengine, but only when I load the index.html from the appengine url. The queries are there (I can see the GET) but nothing is produced.

This is the java in Eclipse:


import android.os.Bundle;
import org.apache.cordova.*;

public class BuzzActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.clearCache();
// super.loadUrl("file:///android_asset/www/index.html");
super.loadUrl("http://lou-oooooooo-todolist.appspot.com/index.html");
// here I load the index.html from the server = not what should be in a native app!! But I do not know otherwise.
// When I do this WITHOUT Phonegap everything is fine....

}
}


This is from your TODOLIST.JS a little adapted:


function cloudQuery() {

plateName = $.jStorage.get("platename");
countrySelect = $.jStorage.get("country");
stateSelect = $.jStorage.get("state");


if (plateName) params = { cond: "name.eq." + plateName };
else params = { sort: "_createdAt.desc", limit: 100 };

$.get("/_je/tasks" + countrySelect + stateSelect, params, function (currentTasks) {
var listHtml = '';

// iterate through the current tasks
for (var ii = 0; ii < currentTasks.length; ii++) {
// add the list item for the task
listHtml += "<li id='task_00'><ul><li></li></ul>" +
"<div class='task-header'>" + currentTasks[ii].name + "</div>" +
"<div class='task-details'>" + currentTasks[ii].description + "<br />" +
"<a href='#' class='task-complete right'></a> " + "</div>" +
"<div class='task-details'>" + currentTasks[ii].due + "</div>" +
"</li>";
} // for
if (listHtml == "") {
if (!plateName) {
listHtml = "<li id='task_00'><ul><li></li></ul>" +
"<div'> NOTHING found: This could be a good thing. !!</div>" +
"</li>";
jQuery("ul#cloudlist").html(listHtml);
}
else {
listHtml = "<li id='task_00'><ul><li></li></ul>" +
"<div'> NOTHING in the Cloud for: " + plateName + " !!</div>" +
"</li>";
jQuery("ul#cloudlist").html(listHtml);
}
}
else {
jQuery("ul#cloudlist").html(listHtml);
}

// refresh the task list display
jQuery("ul#cloudlist li").click(function () {
toggleDetailsDisplay(this);
});

jQuery("ul#cloudlist a.task-complete").click(function () {
// complete the task
alert("Delete this Buzz.");
});
});

}

I think that JSON is not working together with Phonegap.
Now I read something that should be used JSONP, but all I can find is to use JSONP with $.ajax.
Alltogether it is not working at all while it costed me weeks to find all the tools to get so far..........

Can you help me out?

Thank you.

Lou
 
 
subject: json and phonegap (cordova)