[Parse] Hit the API using callFunctionInBackground

Introduction

--Android beginners write it as a memorandum

Main subject

Environmental information

Advance preparation

--Set Parse For Android -[Reference] http://shingaki.me/app/android%E3%81%8B%E3%82%89parse%E3%82%92%E4%BD%BF%E3%81%86/

package XXX.XXXX.XXXXXX;

import com.parse.Parse;
import com.parse.ParseCloud;
import com.parse.ParseException;
import com.parse.FunctionCallback;

import java.util.HashMap;
import java.util.Map;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //Initialize based on application information
        Parse.initialize(new Parse.Configuration.Builder(this)
                .applicationId("YOUR_APPLICATION_ID")
                .clientKey("YOUR_API_APP_CLIENT_KEY")
                .server("YOUR_API_APP_PARSE_URL")
                .build()
        );

        //Set when POST is performed with parameters
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("param_key_1", "value_1");
        parameters.put("param_key_2", "value_2");

        //QUERY_Hit the NAME API
        ParseCloud.callFunctionInBackground("QUERY_NAME", parameters, new FunctionCallback<Map<String, Object>>() {
            @Override
            public void done(Map<String, Object> mapObject, ParseException e) {
                if (e == null) {
                    //No error(When data acquisition is successful)
                    Log.d("data", "[success]" + mapObject);
                }
                else {
                    //There is an error(When data acquisition fails)
                    Log.d("data", "[failed]" + e.getMessage());
                }
            }
        });

        setContentView(R.layout.activity_main);
    }
}

Other referenced sites

Recommended Posts

[Parse] Hit the API using callFunctionInBackground
[Swift] Hit the API using Decodable / Generics
Hit the Docker API in Rust
Try using the Stream API in Java
Try using the Rails API (zip code)
Hit the Salesforce REST API from Java
Try using the Emotion API from Android
ChatWork4j for using the ChatWork API in Java
[API] I tried using the zip code search API
Try using the COTOHA API parsing in Java
How to play MIDI files using the Java Sound API
The API looks like this!
SwiftUI-Display the map using MapKit
Easy way to create a mapping class when using the API