[Solved] HttpUrlConnection working on api level < 11, not working on api level >11 on android

You need to implement all the Network Calls in background Thread via AsyncTask. Here is a dummy template, you can modify it according to your needs: private class LongOperation extends AsyncTask<String, Void, String> { @Override protected String doInBackground(String… params) { //Send your HTTP REQUESTS HERE. return “”; } @Override protected void onPostExecute(String result) { //UPDATE … Read more

[Solved] About RecycleView [closed]

first, u have to create an adapter extending RecyclerView.Adapter class and a ViewHolder, extending RecyclerView.ViewHolder. Adapter and ViewHolder controls how your data will be displayed in RecyclerView. The best examples are in official Google docs on https://developer.android.com/training/material/lists-cards.html?hl=en https://developer.android.com/guide/topics/ui/layout/recyclerview.html solved About RecycleView [closed]

[Solved] How to turn JSON string into table?

easy way could be parse JSON string using GSON like this: String json = “{\”GetReportResult\”:” + ” [” + ” {\”bulan\”:\”4\”,\”total\”:\”2448\”,\”type\”:\”CHEESE1K\”}, ” + ” {\”bulan\”:\”4\”,\”total\”:\”572476\”,\”type\”:\”ESL\”},” + ” {\”bulan\”:\”4\”,\”total\”:\”46008\”,\”type\”:\”ESL500ML\”},” + ” {\”bulan\”:\”5\”,\”total\”:\”5703\”,\”type\”:\”CHEESE1K\”},” + ” {\”bulan\”:\”5\”,\”total\”:\”648663\”,\”type\”:\”ESL\”},” + ” {\”bulan\”:\”5\”,\”total\”:\”51958\”,\”type\”:\”WHP\”},” + ” {\”bulan\”:\”6\”,\”total\”:\”6190\”,\”type\”:\”CHEESE1K\”},” + ” {\”bulan\”:\”6\”,\”total\”:\”443335\”,\”type\”:\”ESL\”},” + ” {\”bulan\”:\”6\”,\”total\”:\”30550\”,\”type\”:\”ESL500ML\”},” + ” ]” + “}”; ReportResults reports = new … Read more

[Solved] Sending variable to PHP server from Android

For Android you can use HTTP Connection URL. An example is mentioned here How to add parameters to HttpURLConnection using POST URL url = new URL(“http://yoururl.com”); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.setReadTimeout(10000); conn.setConnectTimeout(15000); conn.setRequestMethod(“POST”); conn.setDoInput(true); conn.setDoOutput(true); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair(“name”, “Chatura”)); OutputStream os = conn.getOutputStream(); BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(os, … Read more

[Solved] JSON parsing in fragmant [closed]

It seems that your AndroidManifest.xml doesn’t give permission for your app to access the Internet. Your error log states: Permission denied (missing INTERNET permission?) Taken from The Android docs at http://developer.android.com/reference/android/Manifest.permission.html#INTERNET String | INTERNET | Allows applications to open network sockets. Add the following line to your AndroidManifest.xml to allow Internet access: <uses-permission android:name=”android.permission.INTERNET” /> … Read more

[Solved] Serialise List

You can do this easily using JSON.net. Here’s an example: List<Dictionary<String, Object>> Details = new List<Dictionary<string, object>> { new Dictionary<string,object> { {“abc” , “def”}, {“123”, 234} }, new Dictionary<string,object> { {“abc1” , “def1”}, {“1231”, 2341} } }; // serializing to: [{“abc”:”def”,”123″:234},{“abc1″:”def1″,”1231”:2341}] string json = JsonConvert.SerializeObject(Details); // de-serializing to a new List<Dictionary<String, Object>>. List<Dictionary<String, Object>> newDic … Read more

[Solved] sum numeric values in a multidimentional array

Just: var scores = [{ “firstName”: “John”, “value”: 89 }, { “firstName”: “Peter”, “value”: 151 }, { “firstName”: “Anna”, “value”: 200 }, { “firstName”: “Peter”, “value”: 22 }, { “firstName”: “Anna”, “value”: 60 }]; var names = {}; var new_arr = []; scores.forEach(function(entry) { if (names.hasOwnProperty(entry.firstName)) { new_arr[names[entry.firstName]].value += entry.value; } else { names[entry.firstName] = … Read more

[Solved] Create a js object from the output of a for loop

A simple Array.prototype.reduce with Object.assign will do // objectMap reusable utility function objectMap(f,a) { return Object.keys(a).reduce(function(b,k) { return Object.assign(b, { [k]: f(a[k]) }) }, {}) } var arr = { “a”: “Some strings of text”, “b”: “to be encoded”, “c”: “& converted back to a json file”, “d”: “once they’re encoded” } var encodedValues = … Read more

[Solved] How to set JSONArray in model class?

Hope this will help Create a model class and set Offertextmodel as JSONArray public class Offertextlistmodel { JSONArray Offertextmodel; public void setOffertextmodel(JSONArray Offertextmodel) { this.Offertextmodel = Offertextmodel; } } 1 solved How to set JSONArray in model class?

[Solved] Multiple array json parsing under a object in android [closed]

Use from this link and in doInBackground method you must have these code: if (jsonStr != null) { try { JSONObject jsonObj = new JSONObject(jsonStr); JSONObject data = jsonObj.getJSONObject(“data”); // Getting JSON Array node JSONArray ambulance = jsonObj.getJSONArray(“ambulance”); // looping through All ambulance for (int i = 0; i < ambulance.length(); i++) { JSONObject c … Read more

[Solved] how to convert array to ArrayObject with php from json file

To read the data $unsortedData = json_decode(file_get_contents(“data.json”), true); the second paramater true make you get an associative array, instead of getting an array of objects (stdclass) to sort the array: usort($unsortedData, function($a, $b){ return $a[‘serial’] < $b[‘serial’]; }); usort will sort the data according the callback passed as the second parameter, so you can customize … Read more