Good day, there is a button, when you click on this button, a request is sent to the server with a token (the token is sent to the header) and returns the number of allowed attempts to press the button (you can press the button 5 times

{ "result": "ok", "access_token": "rsNQgkedqLcapou9yLSFIy_JRE0D0-enl0T4b-t9EJoFSagYsBzlq2xPRmlsRZW2zfjwYgo4WAPJdGlzNZw5RvKJDMfcX3fQIvbKY8SC3KV2bXdvpRH-aqbNAeyRecJy" } 

. Further, after he returns the number of attempts, a new activity is opened, and there is another button, when you click on it, a request is sent where token and vin sent to the header.

I give the code:

 @GET("/vin/autoru/{vin}") Call<VinInfo> getVinData(@Path("vin") String vin,@Header("Authorization") String token); @OnClick(R.id.bank_button_vinCheckActivity) public void getPledgeData() { if (isConnected() && mVinLength != 12) { showDialog(getString(R.string.loading_data), this); mServerApi.getVinData(mVinCode,mToken).enqueue(new Callback<VinInfo>() { @Override public void onResponse(Call<VinInfo> call, Response<VinInfo> response) { Log.d("mdaq",response.body().toString()); Log.d("MyEnglish", String.valueOf(response.code())); if (response.body() != null) if (response.body().getMarks() != null) { if (response.body().getMarks().size() > 0) { showModelsDialog(response.body().getMarks()); hideDialog(); } } else { if (response.body().getPledge().equals("1")) { getBankInfo(); } else { hideDialog(); makeInfoDialog(getString(R.string.no_bank), true); } } } 

The transfer of the token must be the following: Header

 Authorization: Bearer rsNQgkedqLcapou9yLSFIy_JRE0D0-enl0T4b-t9EJoFSagYsBzlq2xPRmlsRZW2zfjwYgo4WAPJdGlzNZw5RvKJDMfcX3fQIvbKY8SC3KV2bXdvpRH-aqbNAeyRecJy 

I have the code like this:

 mToken = "Bearer " + getIntent().getExtras().getString("token"); 

In this request, a token and vin are transmitted to the server. After that, the server should decrease the count count by 1 and the next time you click on the button from 1 activity, return me 4, not 5 attempts.

And he always returns me 5;

Why do I always return 5?

  • And why don't you just minus every -1? Probably stupid ... :) the first thing that came to mind - iKey
  • @Denis is a great crutch, but it works only temporarily) When I reinstall the application, I will again be able to calmly send requests) - Martinez Toni

0