I have an application with a login screen that connects to a server
and authenticates.
I've looked up numerous tutorials on using Progress Dialogs and
Handlers, and they all explain how to run a seperate thread to (in my
case) send the REST request and check the response. However, my issue
is that my authentication function that I put my code in (below) needs
to return a boolean based on the response type. However, because I am
nesting classes, I can't reference the value returned by my code (the
response).
Here is a snippet:
...
public static boolean auth(String username, String password, Activity
login,Handler handler,int response){
try{
final ProgressDialog progress = ProgressDialog.show(login, "Please
wait...", "Connecting to server...", true);
new Thread(new Runnable(){
public void run(){
try{
URL url = new URL("http://www.procoretech.com/api/
list_projects?login="+username+"&password="+password);
HttpURLConnection uc =
(HttpURLConnection)url.openConnection();
uc.setDoInput(true);
uc.connect();
response = uc.getResponseCode();
//InputSource src = new
InputSource(uc.getInputStream());
} catch (Exception e) {
}
progress.dismiss();
}).start();
...
That code is pasted together from different attempts but hopefully you
can see my problem. I need to pull the response value in the auth
function to return a boolean. Is there a standard way to do this?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.