This is My code,I'm trying to pass the image to listview but i get error.
how can i pass image ? should i download it into local memory first and then send it listview ??
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
JSONObject json = jParser.makeHttpRequest(url_all, "GET", params);
if(json == null)
System.out.println("NULL");
else{
// Check your log cat for JSON reponse
Log.d("All Developers: ", json.toString());
try {
// Checking for SUCCESS TAG
int status = json.getInt(TAG_STATUS);
if (status == 1) {
// products found
// Getting Array of Products
developers = json.getJSONArray(TAG_all);
// looping through All Products
for (int i = 0; i < developers.length(); i++) {
JSONObject c = developers.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_UID);
String name = c.getString(TAG_NAME);
String image = c.getString(TAG_IMAGE_PATH);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_UID, id);
map.put(TAG_NAME, name);
//map.put(TAG_IMAGE_PATH, image);
// adding HashList to ArrayList
developersList.add(map);
//Iamge Download
}
} else {
System.out.println("No Data");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
return null;
}
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
getActivity().runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(getActivity(),
developersList,R.layout.list_data, new String[] { TAG_UID,
TAG_NAME,TAG_IMAGE_PATH},
new int[] { R.id.uid, R.id.name,R.id.image });
// updating listview
lv.setAdapter(adapter);
}
});
}
}
}
Errors
03-30 13:34:03.475: E/BitmapFactory(22326): Unable to decode stream: java.io.FileNotFoundException
You don't have to re-invent the wheel - assuming you have the url to the image you can use nostra13 library for image loading it'll do all the nasty staff for you (cache handling downloading\ saving thumbnail etc..) it also have an exmaple project you can look at to better unnderstand of how to use it.
Related
i am currently trying a tutorial to connect an android app with a server (link: https://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/).
However, i have difficulties with an AsyncTask which is supposed to load the elements of a database. It causes the app to crash and leaves no error logs in the logcat (also tried "no filter"). I surrounded the execute call with a try catch block as well, but the app still crashes. Any ideas what is causing the error?
here are extracts from the code:
public class AllProductsActivity extends ListActivity {
private static String url_all_products = "https://api.androidhive.info/android_connect/get_all_products.php";
...
#Override
public void onCreate(Bundle savedInstanceState) {
try {
new LoadAllProducts().execute();
}catch (Exception e){
e.printStackTrace();
System.out.println(e.getMessage());
}
...
/**
* Background Async Task to Load all product by making HTTP Request
* */
class LoadAllProducts extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(AllProductsActivity.this);
pDialog.setMessage("Loading products. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
/**
* getting All products from url
* */
#Override
protected String doInBackground(String... args) {
// Building Parameters
List<Pair> params = new ArrayList<Pair>();
// getting JSON string from URL
JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);
// Check your log cat for JSON reponse
Log.d("All Products: ", json.toString());
try {
// Checking for SUCCESS TAG
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// products found
// Getting Array of Products
products = json.getJSONArray(TAG_PRODUCTS);
// looping through All Products
for (int i = 0; i < products.length(); i++) {
JSONObject c = products.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_PID);
String name = c.getString(TAG_NAME);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_PID, id);
map.put(TAG_NAME, name);
// adding HashList to ArrayList
productsList.add(map);
}
} else {
// no products found
// Launch Add New product Activity
Intent i = new Intent(getApplicationContext(),
AddNewProductActivity.class);
// Closing all previous activities
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
AllProductsActivity.this, productsList,
R.layout.list_item, new String[] { TAG_PID,
TAG_NAME},
new int[] { R.id.pid, R.id.name });
// updating listview
setListAdapter(adapter);
}
});
}
}
The problem is not with your code implementation. I can see webservice url in your code as
private static String url_all_products = "https://api.androidhive.info/android_connect/get_all_products.php";
The problem is with this web service. That is no longer working. I tested the webservice as you mentioned the link of the tutorial over postman, that is not working any more. Hope you get my point. Feel free to ask me if you have any confusions.
I'm trying to display images in respective ImageViews of a listView created using Simple Adapter. So far the images are downloading fine to a location on disk, and text data is displaying fine in the listView but I'm having trouble displaying the downloaded images to the correct positions of the listView items. My code looks like this so far...
public class MainActivity extends ListActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// More Code Here
...
productList = new ArrayList<HashMap<String, Object>>();
this.getListView().setOnScrollListener(new EndlessScrollListener() {
#Override
public void onLoadMore(int page, int totalItemsCount) {
// Triggered only when new data needs to be appended to the list
// Add whatever code is needed to append new items to your
// AdapterView
customLoadMoreDataFromApi(page);
// or customLoadMoreDataFromApi(totalItemsCount);
}
});
addInitialLoader();
addKeyListener();
// Get listview
lv = getListView();
}
// Append more data into the adapter
public void customLoadMoreDataFromApi(int offset) {
// This method probably sends out a network request and appends new data items to your adapter.
// Use the offset value and add it as a parameter to your API request to retrieve paginated data.
// Deserialize API response and then construct new objects to append to the adapter
//Toast.makeText(MainActivity.this,
//"...loading more items" + offset + "...",
//Toast.LENGTH_LONG).show();
final Toast tost2 = Toast.makeText(MainActivity.this,
"...loading more items" + offset + "...",
Toast.LENGTH_LONG);
tost2.show();
Handler handler2 = new Handler();
handler2.postDelayed(new Runnable() {
#Override
public void run() {
tost2.cancel();
}
}, 1000);
}
public void addInitialLoader() {
// get Internet status
isInternetPresent = cd.isConnectingToInternet();
// check for Internet status
if (isInternetPresent) {
// Internet Connection is Present
// make HTTP requests
new JSONParse().execute();
return;
} else {
// Internet connection is not present
// Ask user to connect to Internet
showAlertDialog(MainActivity.this,
"No Internet Connection",
"You don't have internet connection.", false);
}
}
private class JSONParse extends AsyncTask<String, String, JSONObject> {
private ProgressDialog pDialog;
#Override
protected void onPreExecute() {
super.onPreExecute();
// Some code Here
...
}
#Override
protected JSONObject doInBackground(String... args) {
JSONParser jParser = new JSONParser();
// Clear previous list items
productList.clear();
// Getting JSON from URL
JSONObject json = jParser.makeHttpRequest(url,
"GET", params);
if (json != null) {
try {
// Getting JSON Array
Iterator<String> keys = json.keys();
while (keys.hasNext()) {
String key = keys.next();
String pid = "";
String img = "";
String weight = "";
String name = "";
String desciption = "";
String price = "";
int maxLen = 15;
int maxLen2 = 20;
JSONObject c = json.getJSONObject(key);
String err = c.getString(TAG_ERROR) == "false" ? "" : "true";
if (err == "true") {
pid = "0";
img = "0";
weight = "0";
name = "None";
desciption = "none";
price = "none";
} else {
pid = c.getString(TAG_PID);
img = c.getString(TAG_IMAG);
weight = c.getString(TAG_SIZE);
name = c.getString(TAG_NAME);
desciption = c.getString(TAG_DESCR);
price = c.getString(TAG_PRICE);
}
// tmp hashmap for single contact
HashMap<String, Object> cartitem = new HashMap<String, Object>();
// adding each child node to HashMap key => value
cartitem.put(TAG_PID, pid);
cartitem.put(TAG_IMAG, R.drawable.logo);
cartitem.put(TAG_IMP, img);
cartitem.put(TAG_SIZE, "Size: " + qty);
cartitem.put(TAG_NAME, name);
cartitem.put(TAG_DESCR, desciption);
cartitem.put(TAG_SIZE, weight);
if (err == "") {
cartitem.put(TAG_PRICE, price);
} else {
cartitem.put(TAG_PRICE,
"Error: No cart to show or items are already delivered.");
}
// adding product details to product list
productList.add(cartitem);
}
} catch (JSONException e) {
Log.e("ERROR Exception: ", e.toString());
e.printStackTrace();
}
} else {
// Internet connection is not present
Log.e("ERROR Json: ", "No Internet Available");
}
return null;
}
#Override
protected void onPostExecute(JSONObject json) {
// protected void onPostExecute(Void result) {
super.onPostExecute(json);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
/**
* Updating parsed JSON data into ListView
* */
// Keys used in Hashmap
String[] from = { TAG_SIZE, TAG_NAME, TAG_DESCR, TAG_PRICE, TAG_PID };
// Ids of views in listview_layout
int[] to = { R.id.size, R.id.name, R.id.descr, R.id.price, R.id.pid };
ListAdapter adapter = new SimpleAdapter(MainActivity.this,
productList, R.layout.list_item, from, to);
setListAdapter(adapter);
//Log.i("Adapter Count:", ""+adapter.getCount());
for(int i=0;i<adapter.getCount();i++){
HashMap<String, Object> hm = (HashMap<String, Object>) adapter.getItem(i);
String imgUrl = (String) hm.get(TAG_IMP);
ImageLoaderTask imageLoaderTask = new ImageLoaderTask();
// HashMap<String, Object> hmDownload = new HashMap<String, Object>();
// Only put images that are set
String needle = "img/nophoto.png";
if(!needle.equals(imgUrl)) {
hm.put("img_path", imgUrl);
hm.put("position", i);
Log.i("HM:", hm.toString());
imageLoaderTask.execute(hm);
}
// Starting ImageLoaderTask to download and populate image in the listview
}
}
}
}
/** AsyncTask to download and load an image in ListView */
private class ImageLoaderTask extends AsyncTask<HashMap<String, Object>, Void, HashMap<String, Object>>{
#Override
protected HashMap<String, Object> doInBackground(HashMap<String, Object>... hm) {
InputStream iStream=null;
String imgUrl = (String) hm[0].get("img_path");
//imgUrl = imgUrl.replace("\\/", "");
imgUrl = imgrl + imgUrl;
int position = (Integer) hm[0].get("position");
Log.i("IMGURL:", imgUrl);
URL url;
try {
url = new URL(imgUrl);
// Creating an http connection to communicate with url
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
// Connecting to url
urlConnection.connect();
// Reading data from url
iStream = urlConnection.getInputStream();
// Getting Caching directory
File cacheDirectory = Environment.getExternalStorageDirectory(); //getBaseContext().getCacheDir();
if (cacheDirectory.canWrite()){
File dir = new File (cacheDirectory.getAbsolutePath() + "/IMGDir");
dir.mkdirs();
// Temporary file to store the downloaded image
File tmpFile = new File(dir, "/myimg_"+position+".png");
Log.i("Temp:", cacheDirectory.getAbsolutePath());
// The FileOutputStream to the temporary file
FileOutputStream fOutStream = new FileOutputStream(tmpFile);
// Creating a bitmap from the downloaded inputstream
Bitmap b = BitmapFactory.decodeStream(iStream);
// Writing the bitmap to the temporary file as png file
b.compress(Bitmap.CompressFormat.PNG,100, fOutStream);
// Flush the FileOutputStream
fOutStream.flush();
//Close the FileOutputStream
fOutStream.close();
// Create a hashmap object to store image path and its position in the listview
HashMap<String, Object> hmBitmap = new HashMap<String, Object>();
// Storing the path to the temporary image file
hmBitmap.put("img",tmpFile.getPath());
// Storing the position of the image in the listview
hmBitmap.put("position",position);
Log.i("HMB:", hmBitmap.toString());
// Returning the HashMap object containing the image path and position
return hmBitmap;
}
}catch (Exception e) {
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(HashMap<String, Object> result) {
if(result != null) {
// Getting the path to the downloaded image
String path = (String) result.get("img");
// Getting the position of the downloaded image
int position = (Integer) result.get("position");
// Get listview
//lv = getListView();
// Getting adapter of the listview
SimpleAdapter adapter = (SimpleAdapter) lv.getAdapter();
// Getting the hashmap object at the specified position of the listview
HashMap<String, Object> hm = (HashMap<String, Object>) adapter.getItem(position);
Log.i("POS:", adapter.getItem(position).toString());
// Overwriting the existing path in the adapter
hm.put("image",path);
Log.i("POS 2:", adapter.getItem(position).toString());
// Noticing listview about the dataset changes
//setListAdapter(adapter);
adapter.notifyDataSetChanged();
}
}
}
}
I appreciate any help in finding the connection
Thank you in advance
SimpleAdapter does not have the capability for the "scroll for more" dynamic updating you are trying to do. From the docs:
An easy adapter to map static data to views defined in an XML file.
Once you pass in the list of maps for the data, there's no way for SimpleAdapter to notice that you've updated that list.
Also, to effectively display images even with static data, you need use a subclass with setViewImage overridden or define a ViewBinder that can map images and call adapter.setViewBinder so that the adapter knows how to bind an image to your data.
To achieve what you are trying to do, you will need to create a subclass of BaseAdapter so that you can dynamically add data and correctly bind images to the ImageView.
am working on new reader that is to get news post froma wordpress site to android fone app.
i can get the test(title,date,content) from the json array but i cannot get the image url from the array any ideas
class LoadBrkNews extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Breaking.this);
pDialog.setMessage("Loading News Feeds...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
/**
* getting breaking JSON
* */
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
JSONObject json = jsonParser.makeHttpRequest(BREAK_URL, "GET",
params);
// Check your log cat for JSON reponse
Log.d("BREAKING NEWS JSON: ", json.toString());
try {
if (json.getString("status").equalsIgnoreCase("ok")) {
breakFeeds = json.getJSONArray("posts");
//breakImg = json.getJSONArray(TAG_IMAGE_URL);
// looping through All messages
for (int i = 0; i < breakFeeds.length(); i++) {
JSONObject c = (JSONObject) breakFeeds.getJSONObject(i);
// JSONObject forImg = (JSONObject) breakImg.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_ID);
String title = c.getString(TAG_TITLE);
String content = c.getString(TAG_CONTENT);
String date = c.getString(TAG_DATE);
// remember to remove this line fro production
String urlForImage = c.getString(TAG_IMAGE_URL);
Log.d("attachemtent url",urlForImage);
// Strip off tags
String fcontent = content.replaceAll("<(.*?)\\>"," ");
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_ID, id);
map.put(TAG_TITLE, title);
map.put(TAG_CONTENT, fcontent);
map.put(TAG_DATE, date);
map.put(TAG_IMAGE_URL, urlForImage);
// adding HashList to ArrayList
breakingNewsList.add(map);
ObjectOutput out = new ObjectOutputStream(
new FileOutputStream(tempFile));
String toCache = breakFeeds.toString();
out.writeObject(toCache);
out.close();
Log.d("Write to Cache", "Success");
}
}
} catch (JSONException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(Breaking.this,
breakingNewsList, R.layout.imagelayout,
new String[] { TAG_TITLE, TAG_CONTENT, TAG_DATE,
TAG_IMAGE_URL }, new int[] {
R.id.title, R.id.content, R.id.date,R.id.imglink });
// updating listview
setListAdapter(adapter);
}
});
}
}
`
Since your having trouble only with the image url, I guess it can be either
1. Your data is missing the image url
2. TAG_IMAGE_URL is not matching the key in the data.
Try using some json parsing libary to make things easier.
I get the entire data from the Server by using doInBackground() method as shown below.
class DataLoader extends Activity{
public void onCreate()
{
...............................
new AsyncTask1().execute();
}
class AsyncTask1 extends AsyncTask<String, String, String> {
#Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(DataLoader.this);
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
progressDialog.show();
}
protected String doInBackground(String... args) {
JSONObject json;
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("param1",datafield1));
params.add(new BasicNameValuePair("param2",datafield2));
json = jsonParser.makeHttpRequest(url, "POST", params);
try {
int success = json.getInt(SUCCESS);
if (success == 1) {
products = json.getJSONArray(PRODUCTS);
// looping through All Products
for (int i = 0; i < products.length(); i++) {
JSONObject c = products.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(ID);
String price = c.getString(PRICE);
String name = c.getString(NAME);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(PID, id);
map.put(PRICE, price);
map.put(NAME, name);
..................
// adding HashList to ArrayList
productsList.add(map);
}
return "success";
}
else {
// no materials found for this section
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String msg) {
if( msg != null && msg.equals("success"))
{
progressDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
customadapter=new CustomAdapterList(DataLoader.this, productsList);
listView.setAdapter(adapter);
}
});
}
}
}
As per the above code, I am setting the data to the listview in the onPostExecute() method only after the entire data is loaded. But now I want to implement the CW Endless Adapter with the present code, but as I am new to this, I am unable to get how to move on from here. I included the CWAdapter jar file in the libs folder. Have referred this and searched a lot , but no use. Can some one please help me implementing the endless feature for the data I get?
Basic Idea is to run an AsyncTask when more data is required, that is when uses scrolls to bottom of the list. Here's a quick demo project.
the problem that im having is kind of weird the printstack of the JSON is correct displaying all the element in the table the way that it should the same as for the method String doInBackground(String... args) the problem is in the postExecute method that is displaying the same element in all the element of the listview "the last element in the row of the table to be exact can someone tell me what i did wrong " thank you for your time bellow you will find the class that im talking about thank you
class LoadAllProducts extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(ProDentActivity.this);
pDialog.setMessage("Loading Balance. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
/**
* getting All products from url
* */
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
JSONObject json = jParser.getJSONFromUrl(balanceURL, "GET", params);
// Check your log cat for JSON reponse
Log.d("All Products: ", json.toString());
try {
// Checking for SUCCESS TAG
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// products found
// Getting Array of Products
amount = json.getJSONArray(TAG_BALANCE);
// looping through All Products
for (int i = 0; i < amount.length(); i++) {
JSONObject c = amount.getJSONObject(i);
// Storing each json item in variable
String amount = c.getString(TAG_AMOUNT);
String createdat = c.getString(TAG_CREATEDAT);
//String userid = c.getString(TAG_USERID);
// adding each child node to HashMap key => value
map.put(TAG_AMOUNT, amount);
map.put(TAG_CREATEDAT, createdat);
//map.put(TAG_USERID , userid);
// adding HashList to ArrayList
amountlist.add(map);
}
} else {
// no balance found
// Launch Add New balance Activity
Intent i = new Intent(getApplicationContext(),
ProDentActivity.class);
// Closing all previous activities
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
ListAdapter adapter = new SimpleAdapter(
ProDentActivity.this, amountlist,
R.layout.list_item, new String[] { TAG_AMOUNT,TAG_CREATEDAT},
new int[] { R.id.amount, R.id.createdat });
// updating listview
setListAdapter(adapter);
}
});
}
}
JSON:
{"balance":[{"amount":"50000","created_at":"2012-12-15 02:39:13"},{"amount":"50000","created_at":"2012-12-16 15:29:03"},{"amount":"30000","created_at":"2012-12-17 19:38:07"}],"success":1}
...and the method returns
12-18 02:29:05.797: D/All Products:(885): {"success":1,"balance":[{"amount":"50000","created_at":"2012-12-15 02:39:13"},{"amount":"50000","created_at":"2012-12-16 15:29:03"},{"amount":"30000","created_at":"2012-12-17 19:38:07"}]}
problem fixed i found what i have been doing wrong. the problem was that i didn't define my hash map in the method protected String doInBackground(String... args)
i was defining it in the listactivity anw thank you for your time and help
bellow code to be replaced with the old one
try {
// Checking for SUCCESS TAG
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// products found
// Getting Array of Products
amount = json.getJSONArray(TAG_BALANCE);
// looping through All Products
for (int i = 0; i < amount.length(); i++) {
JSONObject c = amount.getJSONObject(i);
// Storing each json item in variable
String amount = c.getString(TAG_AMOUNT);
String createdat = c.getString(TAG_CREATEDAT);
//String userid = c.getString(TAG_USERID);
// adding each child node to HashMap key => value
HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_AMOUNT, amount);
map.put(TAG_CREATEDAT, createdat);
//map.put(TAG_USERID , userid);
// adding HashList to ArrayList
amountlist.add(map);
}
} else {
// no balance found
// Launch Add New balance Activity
Intent i = new Intent(getApplicationContext(),
ProDentActivity.class);
// Closing all previous activities
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}