This week's book giveaway is in the Java in General forum.
We're giving away four copies of Java by Comparison (eBook) and have Simon Harrer, Jörg Lenhard, Linus Dietz on-line!
See this thread for details.
Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

json and phonegap (cordova)  RSS feed

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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. */
public void onCreate(Bundle savedInstanceState) {
// super.loadUrl("file:///android_asset/www/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>" +
} // for
if (listHtml == "") {
if (!plateName) {
listHtml = "<li id='task_00'><ul><li></li></ul>" +
"<div'> NOTHING found: This could be a good thing. !!</div>" +
else {
listHtml = "<li id='task_00'><ul><li></li></ul>" +
"<div'> NOTHING in the Cloud for: " + plateName + " !!</div>" +
else {

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

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.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!