Here is my Code:
public boolean GetJwtToken(UserModel user){
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(ApiUrl + "api/DoAccess/" + user.Username + "/" + user.Username)
.build();
try {
client.newCall(request).execute();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
When i try to execute this Line
client.newCall(request).execute();
My App closes. When i Try do Debug, i automatically Jump into this class:
I dont find any Thrown Exception.
Hope you guys can Help my:) Thanks a lot!
You are catching an IOException (Checked Exception), but the code is throwing a RuntimeException (unchecked Exception), that's whyh it's not entering into your catch block.
If you want to catch, you need to catch RuntimeException also, but I will investigate on the error, since if the code fails and runs a RuntimeException, there should be another problem.
You probably can see the actual exception by changing catch (IOException e) to catch (Exception e) Possibly the underlying cause is you make network call on main UI thread, use AsynTask if that is the case.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.