0
我正在使用拉力賽Rest API並開發一個拉力賽應用程序。我想根據拉力賽Credentials對用戶進行身份驗證。我設法導入了rally-rest-api-2.2。 1.jar和HTTP罐子。我是指https://github.com/RallyTools/RallyRestToolkitForJava/wiki/User-Guide#setupRALLY Android應用程序的用戶登錄流程
我已經創建了一個登錄頁面,並試圖使用構造函數。如果用戶名和密碼正確,它應該導航到下一頁,我可以進一步處理GET請求等
我的代碼:
package com.example.apetkar.pocrally;
import android.content.Intent;
import android.net.Credentials;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.rallydev.rest.client.BasicAuthClient;
import com.rallydev.rest.client.HttpClient;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
public class MainActivity extends AppCompatActivity {
EditText etemail;
EditText etpass;
Button btnlogin;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etemail=(EditText) findViewById(R.id.edittextemail);
etpass=(EditText) findViewById(R.id.edittextpassword);
btnlogin=(Button)findViewById(R.id.buttonlogin);
btnlogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
try {
getClient();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
});
}
public HttpClient getClient() throws MalformedURLException {
try
{
BasicAuthClient basicAuthClient = new BasicAuthClient(new URI("https://rally1.rallydev.com"),etemail.getText().toString(),etpass.getText().toString());
basicAuthClient.getServer();
basicAuthClient.setApplicationName("Rally-Mobile");
return basicAuthClient;
}
catch (URISyntaxException e)
{
e.printStackTrace();
}
return null;
}
}
任何人都可以建議什麼應該是流量,或者我該如何實現這一目標。謝謝