hellow guys below is my code, i want to get data from api and populate in graph in android but when i call api its shows error please help me, how can i call , api which have no any key
- package com.example.myapplication;
-
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.TextView;
-
- import androidx.appcompat.app.AppCompatActivity;
-
- import com.android.volley.Request;
- import com.android.volley.RequestQueue;
- import com.android.volley.Response;
- import com.android.volley.VolleyError;
- import com.android.volley.toolbox.JsonArrayRequest;
- import com.android.volley.toolbox.JsonObjectRequest;
- import com.android.volley.toolbox.Volley;
-
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
-
- public class MainActivity extends AppCompatActivity {
- private TextView mTextViewResult;
- private RequestQueue mQueue;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- mTextViewResult = findViewById(R.id.text_view_result);
- Button buttonParse = findViewById(R.id.button_parse);
-
- mQueue = Volley.newRequestQueue(this);
-
- buttonParse.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- jsonParse();
-
- }
- });
- }
-
- private void jsonParse() {
-
- String url = "http://marjanjewellers.co/bilal/api.php";
-
- JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
- new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject response) {
- try {
-
-
- JSONArray jsonArray = response.getJSONArray("0"); //here what i do
-
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject employee = jsonArray.getJSONObject(i);
-
-
-
-
-
-
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- error.printStackTrace();
- }
- });
-
- mQueue.add(request);
- }
-
- }
and api response is like this
- [{"id":"1","altitude":"95.5","airpressure":"98.45","temperature":"45.89","pulserate":"85"}]