我有一個.net後端Azure移動服務。我一直試圖從Android客戶端獲取當前用戶信息。我正在使用以下代碼Azure移動服務getCurrentUser
private void authenticate() {
LoginRequest login = new LoginRequest();
login.setUsername(txtUsername.getText().toString());
login.setPassword(txtPassword.getText().toString());
ServiceConstant.mClient.invokeApi("CustomLogin", login, LoginRequest.class,
new ApiOperationCallback<LoginRequest>() {
@Override
public void onCompleted(LoginRequest result,
Exception exception, ServiceFilterResponse response) {
if (exception == null) {
try
{
if (chkRemember.isChecked())
{
cacheUserToken(ServiceConstant.mClient.getCurrentUser());
Toast.makeText(getApplicationContext(),"cache success",Toast.LENGTH_SHORT).show();
}
}
catch (Exception e)
{
Log.e(TAG, "cache fail");
Toast.makeText(getApplicationContext(),
"cache fail",
Toast.LENGTH_SHORT).show();
}
Log.i(TAG, "giris basarili " + result);
Intent intent = new Intent(LoginActivity.this, DeviceScanActivity.class);
startActivity(intent);
} else {
Log.e(TAG, "login fail" + exception);
alert("login", "success\n" + exception);
}
}
});
}
當我嘗試獲取當前用戶時,它將返回null。我應該如何獲取當前用戶信息。我是Azure移動服務的新手,我沒有任何想法來解決這個問題。
您是否設置了身份驗證? https://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-android-get-started-users/ –
是的,我已經加了認證碼 –