Fetch from MySQL and update UI parallely using the Volley library - android

I know there are already some questions associated with this topic.
I have visited every link, but didn't help.
What I am trying to do is fetching the values from MySQL and update the UI parallely without using an AsyncTask.
I am fetching the values based on an unique id which I am getting from another Activity.
I think that since I am using the Volley library I do not need an AsyncTask.
I am getting the values from a database in a toast, but I'm unable to update the UI.
Here is my class
public class DisplayInformationActivity extends Activity implements AppCompatCallback{
private CollapsingToolbarLayout collapsingToolbarLayout;
protected AppCompatDelegate delegate;
protected String UniqueID;
ExpandableListAdapter listAdapter;
ExpandableListView expListView;
List<String> listDataHeader;
HashMap<String,List<String>> listDataChild;
private ProgressDialog loading;
private String Name = "";
private String contact = "";
private String email = "";
protected void onCreate(Bundle savedInstanceState){
UniqueID = getIntent().getStringExtra("uniqueID");
Toast.makeText(this,UniqueID, Toast.LENGTH_LONG).show();
fetchEverything(UniqueID);
super.onCreate(savedInstanceState);
delegate = AppCompatDelegate.create(this,this);
delegate.onCreate(savedInstanceState);
delegate.setContentView(R.layout.displayhallinformation);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
delegate.setSupportActionBar(toolbar);
android.app.ActionBar actionBar = getActionBar();
if(actionBar!=null)
actionBar.setDisplayHomeAsUpEnabled(true);
collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbarLayout.setTitle(Name);
dynamicToolbarColor();
toolBarTextAppearance();
expListView = (ExpandableListView) findViewById(R.id.expandableListView);
prepareListData();
listAdapter = new ExpandableListAdapter(this,listDataHeader,listDataChild);
expListView.setAdapter(listAdapter);
}
private void fetchEverything(String uniqueID) {
RequestQueue mRequestQueue = AppController.getInstance().getRequestQueue();
mRequestQueue.start();
loading = ProgressDialog.show(this,"Loading Information ...","",false,false);
loading.setCancelable(false);
String url = AppConfig.URL_DisplayInformation+"?"+"uniqueID="+uniqueID;
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
loading.dismiss();
showJSON(response);
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
AppController.getInstance().addToRequestQueue(stringRequest);
}
private void showJSON(String response) {
try{
JSONObject jsonObject = new JSONObject(response);
JSONArray result = jsonObject.getJSONArray(AppConfig.JSON_ARRAY);
JSONObject Data = result.getJSONObject(0);
Name = Data.getString(AppConfig.first_name)+" "+Data.getString(AppConfig.last_name);
contact = Data.getString(AppConfig.contact);
email = Data.getString(AppConfig.email);
}catch (JSONException e){
e.printStackTrace();
}
Toast.makeText(this, Name+" "+contact+" "+email, Toast.LENGTH_LONG).show();
}
private void prepareListData() {
listDataHeader = new ArrayList<>();
listDataChild = new HashMap<String,List<String>>();
//Adding header to expandable list view
listDataHeader.add("Information");
listDataHeader.add("Contact");
//Adding child data
List<String> Information = new ArrayList<>();
Information.add("Name : "+Name);
List<String> contact = new ArrayList<>();
contact.add("Contact Number : "+ contact);
contact.add("Email : "+ email);
//Header child data
listDataChild.put(listDataHeader.get(0),Information);
listDataChild.put(listDataHeader.get(1),contact);
}
private void dynamicToolbarColor() {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.images);
Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
#Override
public void onGenerated(Palette palette) {
collapsingToolbarLayout.setContentScrimColor(palette.getMutedColor(ContextCompat.getColor(getApplicationContext(),R.color.colorPrimary)));
collapsingToolbarLayout.setStatusBarScrimColor(palette.getMutedColor(ContextCompat.getColor(getApplicationContext(),R.color.colorPrimaryDark)));
}
});
}
private void toolBarTextAppearance() {
collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.collapsedappbar);
collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.expandedappbar);
}
#Override
public void onSupportActionModeStarted(ActionMode mode) {
}
#Override
public void onSupportActionModeFinished(ActionMode mode) {
}
#Nullable
#Override
public ActionMode onWindowStartingSupportActionMode(ActionMode.Callback callback) {
return null;
}
}
How can I update the UI asynchronously?

How can i update the ui parallely ?
You need to organize the "flow" better.
For example. (indentation meaning method calls)
onCreate
fetchEverything
addToRequestQueue(stringRequest)
onResponse
showJSON
collapsingToolbarLayout.setTitle(Name) // <---- Move this here
prepareListData() // <---- Move this here
expListView = new ExpandableListAdapter...
expListView.setAdapter(listAdapter) // <--- Move this here
Update UI
// ^^^ This section your question?
Currently your code might as well be doing this
onCreate
fetchEverything
addToRequestQueue(stringRequest)
collapsingToolbarLayout.setTitle(Name)
prepareListData()
expListView = new ExpandableListAdapter...
expListView.setAdapter(listAdapter)
...
(some unknown future point)
onResponse
showJSON
Toast.makeText
So, in other words, showJSON (and your Volley data) is not coming in until after you already setup your toolbar and adapter.

Related

how to clear RecyclerView adapter data

Here in my UI, i have used two buttons to load different data to a RecyclerView. First time the data is displaying properly on click of each button. But if i click the button for the second time the data is adding to the adapter twice. I mean the the adapter is not cleared. it is keep on adding the data on click of button. I Think i have to do something with the adapter on click of a button. Can anyone pls let me know how to clear the adapter or where i am going wrong..
Here is the code.
public class GstVendorLocRetrieve extends AppCompatActivity {
private String vault;
private TextView txt;
public static final String DATA_URL = "http://oursite.com/getgstvendorlocation.php?vault_no=";
public static final String DATA_URL1 = "http://oursite.com/getgstcustomerlocation.php?vault_no=";
//Tags for my JSONRes
public static final String TAG_VendorID = "VendorID";
public static final String TAG_CustomerID = "Customer_ID";
public static final String TAG_ADDRESS = "Address";
private Button vendor;
private Button customer;
//Creating a List of superheroes
private List<GstVendLoc> listSuperHeroes;
private List<GstCustLoc> listSuperHeroes1;
//Creating Views
private RecyclerView recyclerView;
private RecyclerView.LayoutManager layoutManager;
private RecyclerView.Adapter adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locationretrieve);
SharedPreferences sharedPreferences = getSharedPreferences(GstLogin.SHARED_PREF_NAME, MODE_PRIVATE);
vault = sharedPreferences.getString(GstLogin.EMAIL_SHARED_PREF,"Not Available");
vendor = (Button) findViewById(R.id.login);
customer = (Button) findViewById(R.id.login1);
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
//Initializing our superheroes list
listSuperHeroes = new ArrayList<>();
listSuperHeroes1 = new ArrayList<>();
vendor.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
recyclerView.setAdapter(null);
getData();
}
});
customer.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
recyclerView.setAdapter(null);
getData1();
}
});
}
//This method will get data from the web api
private void getData(){
//Showing a progress dialog
final ProgressDialog loading = ProgressDialog.show(this,"Loading Data", "Please wait...",false,false);
//Creating a json array request
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(DATA_URL+vault,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
//Dismissing progress dialog
loading.dismiss();
//calling method to parse json array
parseData(response);
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
//Creating request queue
RequestQueue requestQueue = Volley.newRequestQueue(this);
//Adding request to the queue
requestQueue.add(jsonArrayRequest);
}
//This method will parse json data
private void parseData(JSONArray array){
for(int i = 0; i<array.length(); i++) {
GstVendLoc gst1 = new GstVendLoc();
JSONObject json = null;
try {
json = array.getJSONObject(i);
gst1.setVendorID(json.getString(TAG_VendorID));
gst1.setAddress(json.getString(TAG_ADDRESS));
} catch (JSONException e) {
e.printStackTrace();
}
listSuperHeroes.add(gst1);
}
//Finally initializing our adapter
adapter = new CardAdapter17(listSuperHeroes, this);
//Adding adapter to recyclerview
recyclerView.setAdapter(adapter);
}
private void getData1(){
//Showing a progress dialog
final ProgressDialog loading = ProgressDialog.show(this,"Loading Data", "Please wait...",false,false);
//Creating a json array request
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(DATA_URL1+vault,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
//Dismissing progress dialog
loading.dismiss();
//calling method to parse json array
parseData1(response);
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
//Creating request queue
RequestQueue requestQueue = Volley.newRequestQueue(this);
//Adding request to the queue
requestQueue.add(jsonArrayRequest);
}
//This method will parse json data
private void parseData1(JSONArray array){
for(int i = 0; i<array.length(); i++) {
GstCustLoc gst1 = new GstCustLoc();
JSONObject json = null;
try {
json = array.getJSONObject(i);
gst1.setCustomer_ID(json.getString(TAG_CustomerID));
gst1.setAddress(json.getString(TAG_ADDRESS));
} catch (JSONException e) {
e.printStackTrace();
}
listSuperHeroes1.add(gst1);
}
//Finally initializing our adapter
adapter = new CardAdapter18(listSuperHeroes1, this);
//Adding adapter to recyclerview
recyclerView.setAdapter(adapter);
}
}
Use this code for clear RecycleView items
public void clear() {
int size = listSuperHeroes.size();
listSuperHeroes.clear();
notifyItemRangeRemoved(0, size);
}
You need to clear your Array List before you get data second time.
Do this inside parseData1 method before for loop.
listSuperHeroes.clear();
listSuperHeroes1.clear();
What you have to do is Update RecyclerView on button Click , Put below method in your adapter
public void updateData(ArrayList<ViewModel> viewModels) {
items.clear();
items.addAll(viewModels);
notifyDataSetChanged();
}
Than call this method with new data
ArrayList<ViewModel> viewModelsWithNewData = new ArrayList<ViewModel>();
adapter.updateData(viewModelsWithNewData );
you dont need to set adapter after geting data from the online
//Finally initializing our adapter
adapter = new CardAdapter18(listSuperHeroes1, this);
//Adding adapter to recyclerview
recyclerView.setAdapter(adapter);
you can initialize of set the adapter in the on create and add data in the 'listSuperHeroes1' and after parse data you can do adapter.notifyDataSetChanged();
this will change the list data.
and the solution for the getting the previous data you have to remove the all data from the listsuperHeroes1 this will help you if you getting any problem please comment .
I am just improving #Rony's answer.
If you should always check if the ArrayList is not null before attempting to call .size(), otherwise, you might end up with a null pointer exception
if (listSuperHeroes != null && !listSuperHeroes.isEmpty()) {
int size = listSuperHeroes.size();
listSuperHeroes.clear();
notifyItemRangeRemoved(0, size);
}

Getting error:No adapter attached; skipping layout in recyclerview

I tried to fetch the json values from url and shows in listview with adapter in recylerview. but the listview is empty and getting this error 'No adapter attached; skipping layout'. When I tried with the below code its working
for (int i = index; i < end; i++) {
User user = new User();
user.setName("Name " + i);
mUsers.add(user);
}
Here is my part of code, if needed I'll upload complete code
public class OtherNews extends AppCompatActivity {
JSONArray jsonarray;
private RecyclerView mRecyclerView;
private List<User> mUsers = new ArrayList<>();
private UserAdapter mUserAdapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
mRecyclerView = (RecyclerView) findViewById(R.id.recycleView);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
mUserAdapter = new UserAdapter();
new DownloadJSON().execute();
mUserAdapter.setOnLoadMoreListener(new OnLoadMoreListener() {
#Override
public void onLoadMore() {
Log.e("haint", "Load More");
mUsers.add(null);
mUserAdapter.notifyItemInserted(mUsers.size() - 1);
//Load more data for reyclerview
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Log.e("haint", "Load More 2");
//Remove loading item
mUsers.remove(mUsers.size() - 1);
mUserAdapter.notifyItemRemoved(mUsers.size());
//Load data
int index = mUsers.size();
int end = index + 20;
for (int i = index; i < end; i++) {
User user = new User();
user.setName("Name " + i);
user.setEmail("alibaba" + i + "#gmail.com");
mUsers.add(user);
}
mUserAdapter.notifyDataSetChanged();
mUserAdapter.setLoaded();
}
}, 5000);
}
});
}
// DownloadJSON AsyncTask
private class DownloadJSON extends AsyncTask<Void, Void, Void> {
private static final String TAG = "";
#Override
protected void onPreExecute() {
super.onPreExecute();
}
#Override
protected Void doInBackground(Void... params) {
// Create an array
HttpHandler sh = new HttpHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall("http://xxxxxxxxx.in/projects/falcon/getallnews.php?page=2");
if (jsonStr != null) {
try {
JSONObject jsonobject = new JSONObject(jsonStr);
jsonarray = jsonobject.getJSONArray("news");
// Getting JSON Array node
for (int i = 0; i < jsonarray.length(); i++) {
User user = new User();
String title = jsonobject.getString("title");
user.setName(title);
mUsers.add(user);
}
} catch (final JSONException e) {
}
} else {
Log.d(TAG, "someOther)");
}
return null;
}
#Override
protected void onPostExecute(Void args) {
mRecyclerView.setAdapter(mUserAdapter);
}
}
I get the value in this line of code, but couldn't set in list view.
String title = jsonobject.getString("title");
user.setName(title);
The issue is exactly like it sounds, an adapter is not being attached when it needs it. You don't attach it until onPostExecute. Just attach it right from the beginning:
mRecyclerView = (RecyclerView) findViewById(R.id.recycleView);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
mUserAdapter = new UserAdapter();
mRecyclerView.setAdapter(mUserAdapter);
As you modify the adapter in other parts of the code, your RecyclerView will update automatically, so long as you call notifyDataSetChanged() or some related method.

How to pass String into ListView - Android

I have made an ListView with items, qty, rate and retrieved the data from MySQL but I need to add even my "Service Charges" and "Net Amount" to the ListView but I have "Service Charges" and "Net Amount" in the variable not in the MYSQL how can I insert this two into the ListView.
Here is my code:
public void getPostedJobsLocal(){
String url=Config.GET_PAYMENT_BILL;
String url1= local_job_id;
String URL=url+url1;
StringRequest stringRequest = new StringRequest(URL, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
showJSONPosted(response);
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
private void showJSONPosted(String response) {
ParseJSONPayBillLocal pj = new ParseJSONPayBillLocal(response);
pj.parseJSONPayBillLocal();
CustomListPayBillLocal cl = new CustomListPayBillLocal(this, ParseJSONPayBillLocal.items, ParseJSONPayBillLocal.qty,ParseJSONPayBillLocal.rate);
lview.setAdapter(cl);
}
So how can insert the "Service Charges" and "Net Amount" which I have as variable into the ListView?
Its more of a hack. You can add the items to the String arrays before giving it to the Adapter.
Something like this,
private void showJSONPosted(String response) {
ParseJSONPayBillLocal pj = new ParseJSONPayBillLocal(response);
pj.parseJSONPayBillLocal();
ParseJSONPayBillLocal.items = append(ParseJSONPayBillLocal.items, "Service Charges");
ParseJSONPayBillLocal.qty = append(ParseJSONPayBillLocal.qty, "your_qty");
ParseJSONPayBillLocal.rate = append(ParseJSONPayBillLocal.rate, "your_rate");
ParseJSONPayBillLocal.items = append(ParseJSONPayBillLocal.items, "Net Amount");
ParseJSONPayBillLocal.qty = append(ParseJSONPayBillLocal.qty, "your_qty");
ParseJSONPayBillLocal.rate = append(ParseJSONPayBillLocal.rate, "your_rate");
CustomListPayBillLocal cl = new CustomListPayBillLocal(this, ParseJSONPayBillLocal.items, ParseJSONPayBillLocal.qty, ParseJSONPayBillLocal.rate);
lview.setAdapter(cl);
}
public static <T> T[] append(T[] arr, T element) {
final int N = arr.length;
arr = Arrays.copyOf(arr, N + 1);
arr[N] = element;
return arr;
}
Make a model class containing Service Charges and Net Amount
public class MyModel {
String serviceCharges;
String netAmount;
public MyModel (String serviceCharges, String netAmount){
this.serviceCharges= serviceCharges;
this.netAmount= netAmount;
}
public String getServiceCharges() {
return serviceCharges;
}
public void setServiceCharges(String serviceCharges) {
this.serviceCharges= serviceCharges;
}
public String getNetAmount() {
return netAmount;
}
public void setNetAmount(String netAmount) {
this.netAmount= netAmount;
}
}
Now you can create an ArrayList of MyModel class and add your services charges and net amount values:
ArrayList<MyModel> myModelArray = new ArrayList<MyModel>();
myModelArray.add(new MyModel("serviceCharge1","netAmount1"));
myModelArray.add(new MyModel("serviceCharge2","netAmount2"));
.......
.......
Now you can pass this myModelArray to your list adapter for binding data with the list view.
Retrieve values by:
myModelArray.get(position).getServiceCharges();
myModelArray.get(position). getNetAmount();
Note: Shift to retrofit, it is 4 times faster than volley.

Recycler view not rendering the data list

I'm trying to implement a recycler view in fragment using Volley library.
Data is loaded and logged successfully from the server but not displayed at all in the recycler fragment.
The request fetches the data and logs it but nothing renders in the fragment. There are no XML errors.
HitVideoFragment.java
public class HitVideoFragment extends Fragment {
private RecyclerView recyclerView;
private HitVideoAdapter adapter;
private List<HitVideo> hitVideoList = new ArrayList<HitVideo>();
public HitVideoFragment() {
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_hit_video, container, false);
return view;
}
#Override
public void onActivityCreated(Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
//Initializing Views
recyclerView = (RecyclerView) this.getActivity().findViewById(R.id.hitvideo_recycler_view);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this.getActivity());
recyclerView.setHasFixedSize(false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
adapter = new HitVideoAdapter(hitVideoList);
recyclerView.setAdapter(adapter);
//Calling method to get data
//Showing a progress dialog
final ProgressDialog loading = ProgressDialog.show(this.getActivity(),"Loading Data", "Please wait...",false,false);
//Creating a json array request
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(AppConfig.URL_HIT_VIDEOS,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
//Dismissing progress dialog
loading.dismiss();
Log.d("Some tag", "onResponse: "+response.toString());
hitVideoList = new ArrayList<HitVideo>();
for(int i = 0; i<response.length(); i++) {
HitVideo hitVideo = new HitVideo();
JSONObject json = null;
try {
json = response.getJSONObject(i);
hitVideo.setTitle(json.getString("name"));
hitVideo.setUrl(json.getString("url"));
hitVideo.setUsername(json.getString("user_id"));
hitVideo.setHits(json.getInt("hits"));
} catch (JSONException e) {
e.printStackTrace();
}
hitVideoList.add(hitVideo);
}
adapter.notifyDataSetChanged();
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("Hit Video", "Error: " + error.getMessage());
}
}) {
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<>();
Context _context = getActivity().getApplicationContext();
SharedPreferences pref;
String token;
if (_context != null) {
pref = _context.getSharedPreferences(Config.PREF_NAME, Config.PRIVATE_MODE);
if (pref != null) {
token = pref.getString(Config.USER_TOKEN, null);
headers.put("Authorization", "Bearer " + token);
}
}
return headers;
}
};
//Creating request queue
RequestQueue requestQueue = Volley.newRequestQueue(this.getActivity());
//Adding request to the queue
requestQueue.add(jsonArrayRequest);
}
This is not throwing any exceptions. And the model and adapters are doing their job fine. Thanks in advance.
I am probably too late to this,
But I had the same issue and I fixed it by returning the list.size() on the getItemCout() method in the Adapter class.

How to display details of listview selected item on another activity?

Here is my code... which i displayed listview data... Now i want to fetch other details under this id
I want to fetch from database based on the Growers ID. Which is get from the listview
public class FarmerDetails extends Activity implements OnClickListener
{
private TextView tv;
private Button btnView;
private TextView textViewResult;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.farmerdetails);
btnView = (Button) findViewById(R.id.bView);
textViewResult = (TextView) findViewById(R.id.textViewResult);
btnView.setOnClickListener(this);
tv=(TextView) findViewById(R.id.tv1);
}
private void getData(final String value) {
Intent i = getIntent();
String code = i.getStringExtra("itemValue");
tv.setText("Grower's ID: "+code);
String url = Config.DATA_Details+tv.getText().toString().trim();
StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
showJSON(response);
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(FarmerDetails.this,error.getMessage().toString(),Toast.LENGTH_LONG).show();
}
});
}
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
private void showJSON(String response){
String ccri="";
String name="";
String address="";
String taluk="";
String punch = "";
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray result = jsonObject.getJSONArray(Config.JSON_ARRAY);
JSONObject farmerData = result.getJSONObject(0);
ccri=farmerData.getString(Config.KEY_CCRI);
name = farmerData.getString(Config.KEY_NAME);
address = farmerData.getString(Config.KEY_ADDRESS);
taluk = farmerData.getString(Config.KEY_TALUK);
punch=farmerData.getString(Config.KEY_PUNCH);
}
catch (JSONException e)
{
e.printStackTrace();
}
textViewResult.setText("CCRI Code:\t"+ccri+"Name:\t"+name+"\nAddress:\t" +address+ "\nTaluk:\t"+taluk+"\nPunchayat:\t"+punch);
}
#Override
public void onClick(View v) {
getData();
}
}
In my code only ID is displaying... fetching is not performing.. Plz help!!
this is kinda complicated.
you'll have to check out if ur url is right. Print the url in
console and type it in some browser do the GET request. If there's
no response, well it might be your problem. Maybe you did not
compose the url right.
if there's some response in step 1, ask the server guy what's going
on there. and wait.

Categories

Resources