我有一个改造小问题。我想调用一个url(它是一个具有端口号的修复IP),并且它没有返回值。我的代码运行,但没有发生。 (这将是一个家庭自动化系统,和此代码应打开我的车库,该服务器是一个码头的Servlet在R.PI)翻新2.3网址调用无返回值
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button garageBtn = (Button)findViewById(R.id.garageBtn);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://192.168.96.100:8080/")
.build();
GarageApi service = retrofit.create(GarageApi.class);
garageBtn.setOnClickListener((View v) -> {
service.garagemove();
//Log.d("Retrofit", service.garagemove().toString());
});
}}
public interface GarageApi {
@GET("garage")
Call<ResponseBody> garagemove();
}
请帮忙解决我的问题。
我也试过,但没有发生。 –
客户端方法不会返回任何内容,因此您应该检查是否已达到(后端)api端点。也许问题在那里。 – db80