Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Studio & Favoriot #1

Open
atjamil opened this issue Feb 5, 2022 · 0 comments
Open

Android Studio & Favoriot #1

atjamil opened this issue Feb 5, 2022 · 0 comments

Comments

@atjamil
Copy link

atjamil commented Feb 5, 2022

Hi Lintang Wisesa,

Thank you for the code for how to use Android App Inventor with favoriot.
I've been trying to use Android studio to access/read my data in favoriot, but no success.
I use jason object to get the favoriot data and put the API key in the header, but no success.
Any idea why?
Here is my soure code:

String url = "https://api.favoriot.com/v1/streams?device_developer_id=Soil_Moisture@atxxyy&max=1&order=DESC";

JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener() {

                    @Override
                    public void onResponse(JSONObject response) {
                        Log.d(TAG, response.toString());
                    }
                },


                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.d(TAG, error.toString());
                    }
                }) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<>();
	   String auth ="my auth key here"
                headers.put("apikey", auth);
                return headers;
            }


            }
        };
        queue.add(jsonObjectRequest);

Regards

@atjamil atjamil changed the title Andorid Studior & Favoriot Android Studio & Favoriot Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant