我找不到代码。我想要这个;
例如
JSONObject result = function("url",paramsArrayList);
txt.setText(result.getString["result1"]);
我想用这么基本,请帮帮我,我应该用什么?谢谢。。。
要从 php 发送和接收数据,您需要在 android 端实现 HTTP 客户端。我强烈建议您使用Retrofit,一个适用于Android和Java的类型安全的HTTP客户端。
http://square.github.io/retrofit/
//delcare API interface
public interface TaskService {
@GET("/tasks")
Call<List<Task>> getTasks();
}
//Asynchronous Request
TaskService taskService = ServiceGenerator.createService(TaskService.class);
Call<List<Task>> call = taskService.getTasks();
call.enqueue(new Callback<List<Task>>() {
@Override
public void onResponse(Call<List<Task>> call, Response<List<Task>> response) {
if (response.isSuccessful()) {
// tasks available
} else {
// error response, no access to resource?
}
}
@Override
public void onFailure(Call<List<Task>> call, Throwable t) {
// something went completely south (like no internet connection)
Log.d("Error", t.getMessage());
}
}