0
我想发送一个请求到服务器,当我从服务器得到响应我想将手机从静音模式切换到正常模式。我正在使用改造,而我是新的。使用改造请求和响应做特定功能
这是我如何做请求和响应流程:
Call<ServerResponse3> response3 = requestInterface.chec(ProfileFragment.Global.email);
response3.enqueue(new Callback<ServerResponse3>() {
@Override
public void onResponse(Call<ServerResponse3> call, retrofit2.Response<ServerResponse3> response3) {
ServerResponse3 resp = response3.body();
Toast.makeText(BService.this, resp.getResult(), LENGTH_LONG).show();
Toast.makeText(BService.this, ProfileFragment.Global.ID, LENGTH_LONG).show();
final AudioManager mode = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
if (resp.getResult().contains("true")) {
//Normal Mode Programatically
mode.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
} else {
//Silent Mode Programatically
mode.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}
}
这里是接口部分:
@GET("project5/web/normal")
Call<ServerResponse3> chec (@Query("email") String email);
我也是这样做的权利或有什么不对?
你有什么错误? –
@MuraliPrajapati无法解析getSystemService –