Click here to Skip to main content
15,891,908 members
Home / Discussions / Android
   

Android

 
GeneralRe: SQLite problem Pin
Member 109990708-Aug-14 0:51
Member 109990708-Aug-14 0:51 
GeneralRe: SQLite problem Pin
Richard MacCutchan8-Aug-14 2:09
mveRichard MacCutchan8-Aug-14 2:09 
GeneralRe: SQLite problem Pin
Member 109990708-Aug-14 3:40
Member 109990708-Aug-14 3:40 
GeneralRe: SQLite problem Pin
Richard MacCutchan8-Aug-14 5:41
mveRichard MacCutchan8-Aug-14 5:41 
GeneralRe: SQLite problem Pin
Member 109990708-Aug-14 3:41
Member 109990708-Aug-14 3:41 
GeneralRe: SQLite problem Pin
Member 109990708-Aug-14 3:18
Member 109990708-Aug-14 3:18 
AnswerRe: SQLite problem Pin
Dominic Burford17-Sep-14 20:57
professionalDominic Burford17-Sep-14 20:57 
Questionjson parser images shown in lstview please help me Pin
Member 109237866-Aug-14 1:42
Member 109237866-Aug-14 1:42 
my json parser
------------------------
{
"default_bundels": [ "P0001", "P0002", "P0003", "P0004", "P0005", "P0006" ],
"product_bundles": {
"P0001": [ { "name": "Animals", "cost": 0, "images_counts": 6, "category": "Animals" } ],
"P0002": [ { "name": "Buildings", "cost": 0, "images_counts": 6, "category": "Buildings" } ],
"P0003": [ { "name": "Cars", "cost": 0, "images_counts": 6, "category": "Cars" } ],
"P0004": [ { "name": "Sports", "cost": 0, "images_counts": 6, "category": "Sports" } ],
"P0005": [ { "name": "Fruits", "cost": 0, "images_counts": 6, "category": "Fruits" } ],
"P0006": [ { "name": "Personalities", "cost": 0, "images_counts": 6, "category": "Personalities" } ],
"P0007": [ { "name": "AnimationMovies", "cost": 0.99, "images_counts": 15, "category": "AnimationMovies" } ],
"P0008": [ { "name": "ArtPaintings", "cost": 0.99, "images_counts": 10, "category": "ArtPaintings" } ],
"P0009": [ { "name": "Cartoons", "cost": 0.99, "images_counts": 8, "category": "Cartoons" } ],
"P0010": [ { "name": "Celebrities", "cost": 0.99, "images_counts": 10, "category": "Celebrities" } ],
"P0011": [ { "name": "ExploreIndia", "cost": 0.99, "images_counts": 10, "category": "ExploreIndia" } ],
"P0012": [ { "name": "Flowers", "cost": 0.99, "images_counts": 8, "category": "Flowers" } ],
"P0013": [ { "name": "FoodAndDrink", "cost": 0.99, "images_counts": 11, "category": "FoodAndDrink" } ],
"P0014": [ { "name": "Historical", "cost": 0.99, "images_counts": 8, "category": "Historical" } ],
"P0015": [ { "name": "KidsAndBabies", "cost": 0.99, "images_counts": 8, "category": "KidsAndBabies" } ],
"P0016": [ { "name": "Nature", "cost": 0.99, "images_counts": 9, "category": "Nature" } ]
}
}

i tried like this
------------------------------
private class GetContacts extends AsyncTask<void, void,="" void=""> {

@Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();

}

@Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instance
ServiceHandler sh = new ServiceHandler();

// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);

Log.d("Response: ", "> " + jsonStr);

if (jsonStr != null) {
try {



ArrayList cat=new ArrayList();
JSONObject jsonObj = new JSONObject(jsonStr);


JSONArray jsonArray=jsonObj.getJSONArray(TAG_CAT);

for (int i = 0; i < jsonArray.length(); i++) {

JSONObject c = jsonArray.getJSONObject(i);

String name = c.getString(TAG_NAME);
String cost = c.getString(TAG_COST);
String images_count = c.getString(TAG_IMAGES_COUNT);
String category = c.getString(TAG_CATEGORY);




// for (int i = 0; i < jsonArray.length(); i++) {
//
// JSONObject c = jsonArray.getJSONObject(i);
//
//
// HashMap<string, string=""> contact = new HashMap<string, string="">();





// Getting JSON Array node
// contacts = jsonObj.getJSONArray(TAG_CAT);
//
// // looping through All Contacts
// for (int i = 0; i < contacts.length(); i++) {
// JSONObject c = contacts.getJSONObject(i);
//
// contacts.getJSONObject(i);
//
// //Contact contact=new Contact();
//
// String name = c.getString(TAG_NAME);
// String cost = c.getString(TAG_COST);
// String images_count = c.getString(TAG_IMAGES_COUNT);
// String category = c.getString(TAG_CATEGORY);
//
//
//
// // tmp hashmap for single contact
// HashMap<string, string=""> contact = new HashMap<string, string="">();
//
// // adding each child node to HashMap key => value
//
// contact.put(TAG_NAME, name);
// contact.put(TAG_COST, cost);
// contact.put(TAG_IMAGES_COUNT, images_count);
// contact.put(TAG_CATEGORY, category);
//
//
//
//
// // adding contact to contact list
//imagesList.add(contact);
}

} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}


return null;
}

@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
MainActivity.this, imagesList,
R.layout.list_item, new String[] {TAG_CATEGORY}, new int[] { R.id.mobile});

lv.setAdapter(adapter);
}

}

}



i got errors like this
---------------------

08-06 17:09:00.479: W/System.err(1312): org.json.JSONException: Value {"P0010":[{"images_counts":10,"cost"Blush | :O .99,"category":"Celebrities","name":"Celebrities"}],"P0011":[{"images_counts":10,"cost"Blush | :O .99,"category":"ExploreIndia","name":"ExploreIndia"}],"P0002":[{"images_counts":6,"cost"Blush | :O ,"category":"Buildings","name":"Buildings"}],"P0012":[{"images_counts":8,"cost"Blush | :O .99,"category":"Flowers","name":"Flowers"}],"P0003":[{"images_counts":6,"cost"Blush | :O ,"category":"Cars","name":"Cars"}],"P0013":[{"images_counts":11,"cost"Blush | :O .99,"category":"FoodAndDrink","name":"FoodAndDrink"}],"P0014":[{"images_counts":8,"cost"Blush | :O .99,"category":"Historical","name":"Historical"}],"P0001":[{"images_counts":6,"cost"Blush | :O ,"category":"Animals","name":"Animals"}],"P0015":[{"images_counts":8,"cost"Blush | :O .99,"category":"KidsAndBabies","name":"KidsAndBabies"}],"P0006":[{"images_counts":6,"cost"Blush | :O ,"category":"Personalities","name":"Personalities"}],"P0016":[{"images_counts":9,"cost"Blush | :O .99,"category":"Nature","name":"Nature"}],"P0007":[{"images_counts":15,"cost"Blush | :O .99,"category":"AnimationMovies","name":"AnimationMovies"}],"P0004":[{"images_counts":6,"cost"Blush | :O ,"category":"Sports","name":"Sports"}],"P0005":[{"images_counts":6,"cost"Blush | :O ,"category":"Fruits","name":"Fruits"}],"P0008":[{"images_counts":10,"cost"Blush | :O .99,"category":"ArtPaintings","name":"ArtPaintings"}],"P0009":[{"images_counts":8,"cost"Blush | :O .99,"category":"Cartoons","name":"Cartoons"}]} at product_bundles of type org.json.JSONObject cannot be converted to JSONArray
08-06 17:09:00.579: W/System.err(1312): at org.json.JSON.typeMismatch(JSON.java:100)
08-06 17:09:00.839: W/System.err(1312): at org.json.JSONObject.getJSONArray(JSONObject.java:548)
08-06 17:09:01.039: W/System.err(1312): at com.jsonexample.MainActivity$GetContacts.doInBackground(MainActivity.java:119)
08-06 17:09:01.079: W/System.err(1312): at com.jsonexample.MainActivity$GetContacts.doInBackground(MainActivity.java:1)
08-06 17:09:01.309: W/System.err(1312): at android.os.AsyncTask$2.call(AsyncTask.java:264)
08-06 17:09:01.350: W/System.err(1312): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-06 17:09:01.579: W/System.err(1312): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-06 17:09:01.659: W/System.err(1312): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
08-06 17:09:01.839: W/System.err(1312): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-06 17:09:01.879: W/System.err(1312): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-06 17:09:02.029: W/System.err(1312): at java.lang.Thread.run(Thread.java:856)
AnswerRe: json parser images shown in lstview please help me Pin
khaingwarswe16-Aug-14 6:59
khaingwarswe16-Aug-14 6:59 
QuestionAndroid and Network device Pin
khaingwarswe6-Aug-14 0:01
khaingwarswe6-Aug-14 0:01 
QuestionRe: Android and Network device Pin
David Crow7-Aug-14 5:45
David Crow7-Aug-14 5:45 
QuestionAnimate SVG image while it is drawn on SVGImageView. Pin
Member 109832715-Aug-14 0:44
Member 109832715-Aug-14 0:44 
QuestionAndroid json parser . please do the android json parserand show the images in listview Pin
Member 109237864-Aug-14 1:53
Member 109237864-Aug-14 1:53 
AnswerRe: Android json parser . please do the android json parserand show the images in listview Pin
Paul Conrad4-Aug-14 15:45
professionalPaul Conrad4-Aug-14 15:45 
AnswerRe: Android json parser . please do the android json parserand show the images in listview Pin
Dilan Shaminda4-Aug-14 18:56
professionalDilan Shaminda4-Aug-14 18:56 
Questioni am new to android development,issue with eclipse editor hover on variable opens to browser Pin
babushashir2-Aug-14 7:11
babushashir2-Aug-14 7:11 
QuestionANDROID SQLITE Pin
Member 1097990729-Jul-14 20:28
Member 1097990729-Jul-14 20:28 
QuestionRe: ANDROID SQLITE Pin
David Crow1-Aug-14 4:15
David Crow1-Aug-14 4:15 
AnswerRe: ANDROID SQLITE Pin
Member 109893584-Aug-14 0:31
Member 109893584-Aug-14 0:31 
GeneralRe: ANDROID SQLITE Pin
Richard MacCutchan4-Aug-14 0:46
mveRichard MacCutchan4-Aug-14 0:46 
Questionhow to develop dictionar apps in android enlish to enlish Pin
Member 1097992129-Jul-14 20:24
Member 1097992129-Jul-14 20:24 
SuggestionRe: how to develop dictionar apps in android enlish to enlish Pin
David Crow1-Aug-14 4:16
David Crow1-Aug-14 4:16 
QuestionURGENT:Upload images to mobile application through web service Pin
slSoftware27-Jul-14 18:57
slSoftware27-Jul-14 18:57 
Questionget image from server Pin
Member 1078316923-Jul-14 1:56
Member 1078316923-Jul-14 1:56 
QuestionRe: get image from server Pin
David Crow1-Aug-14 4:18
David Crow1-Aug-14 4:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.