Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid JSon Error In Android
    primarykey
    data
    text
    <p>I am working with yummly api in android and I am getting an error with my parse code. I have attached my json code and java code below. I have used the json with other api and it works, I am just not seeing what I am missing. Any insight would be wonderful.</p> <p><strong>JSON:</strong></p> <pre><code>{ "attribution":{ "html":"&lt;a href='http://www.yummly.com/recipes/onion-soup'&gt;onion soup recipes&lt;/a&gt; search powered by &lt;img alt='Yummly' src='http://static.yummly.com/api-logo.png'/&gt;", "url":"http://www.yummly.com/recipes/onion-soup", "text":"onion soup recipes: search powered by Yummly", "logo":"http://static.yummly.com/api-logo.png" }, "totalMatchCount":41710, "facetCounts":{ }, "matches":[ { "attributes":{ "course":[ "Soups" ] }, "flavors":{ "salty":0.16666666666666666, "sour":0.16666666666666666, "sweet":0.16666666666666666, "bitter":0.16666666666666666, "meaty":0.16666666666666666, "piquant":0.0 }, "rating":4, "id":"Miyabi-Japanese-Onion-Soup-Food_com-111654", "smallImageUrls":[ "http://i.yummly.com/Miyabi-Japanese-Onion-Soup-Food_com-111654-204787.s.jpg" ], "sourceDisplayName":"Food.com", "totalTimeInSeconds":2100.0, "ingredients":[ "carrot", "garlic cloves", "chicken broth", "beef broth", "onions", "onions", "mushroom", "green onion" ], "recipeName":"Miyabi Japanese Onion Soup" }, { "attributes":{ "course":[ "Soups" ], "cuisine":[ "French" ] }, "flavors":{ "salty":0.6666666666666666, "sour":0.3333333333333333, "sweet":0.6666666666666666, "bitter":0.3333333333333333, "meaty":0.3333333333333333, "piquant":0.0 }, "rating":5, "id":"French-onion-soup-348995", "smallImageUrls":[ "http://i.yummly.com/French-onion-soup-348995-313707.s.jpg" ], "sourceDisplayName":"Every Day with Rachael Ray", "totalTimeInSeconds":2100.0, "ingredients":[ "swiss cheese", "dry red wine", "sweet onions", "beef broth", "croutons" ], "recipeName":"French Onion Soup" } ], "criteria":{ "requirePictures":false, "excludedIngredients":[ ], "allowedIngredients":[ ], "terms":[ "onion", "soup" ], "facetFields":[ ], "resultsToSkip":1, "maxResults":0 } } </code></pre> <p><strong>Java class:</strong></p> <pre><code>private class DownloadJSON extends AsyncTask&lt;Void, Void, Void&gt; { @Override protected void onPreExecute() { super.onPreExecute(); // Create a progressdialog mProgressDialog = new ProgressDialog(MainActivity.this); // Set progressdialog title mProgressDialog.setTitle("Android JSON Parse Tutorial"); // Set progressdialog message mProgressDialog.setMessage("Loading..."); mProgressDialog.setIndeterminate(false); // Show progressdialog mProgressDialog.show(); } @Override protected Void doInBackground(Void... params) { // Create an array arraylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); // Retrieve JSON Objects from the given URL address jsonobject = JSONfunctions .getJSONfromURL(yummlyurl); try { // Locate the array name in JSON jsonarray = jsonobject.getJSONArray("matches"); for (int i = 0; i &lt; jsonarray.length(); i++) { HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); jsonobject = jsonarray.getJSONObject(i); // Retrive JSON Objects map.put("Recipe Name", jsonobject.getString("recipeName")); map.put("Ingredients", "Hello"); map.put("Id", "Hello"); map.put("flag", "Hello"); // Set the JSON Objects into the array arraylist.add(map); } } catch (JSONException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void args) { // Locate the listview in listview_main.xml listview = (ListView) findViewById(R.id.listview); // Pass the results into ListViewAdapter.java adapter = new ListViewAdapter(MainActivity.this, arraylist); // Set the adapter to the ListView listview.setAdapter(adapter); // Close the progressdialog mProgressDialog.dismiss(); } </code></pre> <p><strong>Log:</strong></p> <pre><code>09-08 11:16:52.954: E/WindowManager(2588): Activity com.androidbegin.jsonparsetutorial.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{a67ad4d8 V.E..... R....... 0,0-480,243} that was originally added here 09-08 11:16:52.954: E/WindowManager(2588): android.view.WindowLeaked: Activity com.androidbegin.jsonparsetutorial.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{a67ad4d8 V.E..... R....... 0,0-480,243} that was originally added here 09-08 11:16:52.954: E/WindowManager(2588): at android.view.ViewRootImpl.&lt;init&gt;(ViewRootImpl.java:354) 09-08 11:16:52.954: E/WindowManager(2588): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:216) 09-08 11:16:52.954: E/WindowManager(2588): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) 09-08 11:16:52.954: E/WindowManager(2588): at android.app.Dialog.show(Dialog.java:281) 09-08 11:16:52.954: E/WindowManager(2588): at com.androidbegin.jsonparsetutorial.MainActivity$DownloadJSON.onPreExecute(MainActivity.java:53) 09-08 11:16:52.954: E/WindowManager(2588): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586) 09-08 11:16:52.954: E/WindowManager(2588): at android.os.AsyncTask.execute(AsyncTask.java:534) 09-08 11:16:52.954: E/WindowManager(2588): at com.androidbegin.jsonparsetutorial.MainActivity.onCreate(MainActivity.java:36) 09-08 11:16:52.954: E/WindowManager(2588): at android.app.Activity.performCreate(Activity.java:5104) 09-08 11:16:52.954: E/WindowManager(2588): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 09-08 11:16:52.954: E/WindowManager(2588): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 09-08 11:16:52.954: E/WindowManager(2588): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 09-08 11:16:52.954: E/WindowManager(2588): at android.app.ActivityThread.access$600(ActivityThread.java:141) 09-08 11:16:52.954: E/WindowManager(2588): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 09-08 11:16:52.954: E/WindowManager(2588): at android.os.Handler.dispatchMessage(Handler.java:99) 09-08 11:16:52.954: E/WindowManager(2588): at android.os.Looper.loop(Looper.java:137) 09-08 11:16:52.954: E/WindowManager(2588): at android.app.ActivityThread.main(ActivityThread.java:5041) 09-08 11:16:52.954: E/WindowManager(2588): at java.lang.reflect.Method.invokeNative(Native Method) 09-08 11:16:52.954: E/WindowManager(2588): at java.lang.reflect.Method.invoke(Method.java:511) 09-08 11:16:52.954: E/WindowManager(2588): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 09-08 11:16:52.954: E/WindowManager(2588): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 09-08 11:16:52.954: E/WindowManager(2588): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload