I am using Backendless.UserService.login for logging in users. But problem is that it is showing no error and also user is not logged in.
Here is the code i am using.
package paizy.blackdogs.paizy;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.backendless.Backendless;
import com.backendless.BackendlessUser;
import com.backendless.async.callback.AsyncCallback;
/**
* Created by Milan Marwadi on 08-02-2016.
*/
public class Login extends Activity implements View.OnClickListener {
Button login_btn;
EditText email;
EditText passwd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
Backendless.initApp(this, BackendSettings.Application_Id, BackendSettings.SecretKey, BackendSettings.appVersion);
login_btn = (Button) findViewById(R.id.login_button);
login_btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id){
case R.id.login_button:
email = (EditText) findViewById(R.id.email);
passwd = (EditText) findViewById(R.id.password);
CharSequence email_id = email.getText();
CharSequence password = passwd.getText();
LoadingCallback<BackendlessUser> loginCallback = createLoginCallback();
loginCallback.showLoading();
Toast.makeText(this,"Logged in : Name is ",Toast.LENGTH_LONG).show();
loginUser(email_id.toString(), password.toString(), loginCallback);
Toast.makeText(this,"Second",Toast.LENGTH_LONG).show();
}
}
private LoadingCallback<BackendlessUser> createLoginCallback() {
return new LoadingCallback<BackendlessUser>(this,"Sending Login info")
{
public void handleResponse(BackendlessUser loggedUser){
super.handleResponse(loggedUser);
Toast.makeText(Login.this,String.format("Logged in : Name is %s", loggedUser.getObjectId()),Toast.LENGTH_LONG).show();
}
};
}
private void loginUser(String s, String s1, AsyncCallback<BackendlessUser> loginCallback) {
Backendless.UserService.login(s,s1,loginCallback);
}
}