I have an application for android which should login on the server for further work. So for this, I created an interface with this code:
import retrofit2.Call; import retrofit2.http.Field; import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST; public interface APIService { Call<LoginRequest> savePost(@Field("id") Integer id, @Field("password") String password); } and I have two fields for input where I have to enter a login and password, the data from the fields are transmitted to the server in json format, and my problem is that when I send to the server I get an error which is that the data in the login field is Currently being sent to an int and I cannot translate this data from the string format into an int:
Integer id = Integer.valueOf((mEmailView.getText().toString().trim())); String password = mPasswordView.getText().toString().trim(); and my application flies all the time because an error in this field when translating from one format to another, and therefore the application crashes in me, I kind of looked to translate normally, but for some reason it does not work correctly. Mistake:
--------- beginning of crash 07-11 02:30:18.411 6910-6910/com.example.developer_4.test_log E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.developer_4.test_log, PID: 6910 java.lang.NumberFormatException: For input string: "jdnjsnj" at java.lang.Integer.parseInt(Integer.java:521) at java.lang.Integer.valueOf(Integer.java:611) at com.example.developer_4.test_log.LoginActivity$2.onClick(LoginActivity.java:105) at android.view.View.performClick(View.java:5637) at android.view.View$PerformClick.run(View.java:22429) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) --------- beginning of system If someone faced a similar problem or knows how to help me, I will be very grateful.