我在Android Studio下,我正在尝试调试我的应用。
所以我在不同的地方放了4个断点(见下面的代码),1号和4号被叫,但不是2号和3号。这是我寻找原因的一天,但我不知道。 (它确实发生在很多其他断点上)。
我试图删除断点3处的行(稍后调用断点4)以查看它是否实际被调用,是的,如果我删除它没有任何反应(断点4永远不会被调用)。有人知道为什么吗?我错过了什么吗?
这是我的代码:
AuthenticationActivity.java
checkAccount(){
tokenGetter = new TokenGetter();
tokenGetter.setParameter(accountManagerFuture, accounts[0]);
tokenGetter.execute(); //BREAKPOINT 1
}
private class TokenGetter extends AsyncTask{
AccountManagerFuture<Bundle> accountManagerFuture;
Account account;
public void setParameter(AccountManagerFuture<Bundle> accountManagerFuture, Account account) {
this.accountManagerFuture = accountManagerFuture;
this.account = account;
}
@Override
protected Object doInBackground(Object[] objects) {
Bundle b = null;
try {
b = accountManagerFuture.getResult(2000, TimeUnit.MILLISECONDS); //BREAKPOINT 2
} catch (Exception e) {
//e.printStackTrace();
}
return b;
}
@Override
protected void onPostExecute(Object b) {
if(b != null)
{
TOKEN = ((Bundle)b).get(AccountManager.KEY_AUTHTOKEN).toString();
accountManager.setAuthToken(account, accountType,TOKEN);
}
profileDataFactory = new ProfileDataFactory();
profileDataFactory.setParameters(getApplicationContext(), "users/me", ReceiveDataService.PROFILE); //BREAKPOINT 3
}
}
ReceiveDataService.java
int responseCode = urlConnection.getResponseCode(); //BREAKPOINT 4
if (responseCode != 200) {
if(responseCode == 401) {
throw new Exception(TOKEN_EXPIRED);
} else {
if (BuildConfig.DEBUG) Log.e(TAG,"Status Error CODE : " + responseCode);
throw new Exception(REQUEST_FAILED);
}
}