--Android beginners write it as a memorandum
--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);
}
}
Recommended Posts