I am trying to login to VK using VKsdk for android. When I press the button a login screen shows up, I press "allow" and login screen closes. But my app just hangs! And when i restart an App, I am still logged out. What am I doing wrong?
Here is code:
@Override
public void onClick(View v) {
if(!VKSdk.isLoggedIn()){
VKSdk.login(MainActivity.this, VKScope.AUDIO);
}
}
Take a look at the demo code.
Did you override onActivityResult
in your Activity ? Something like :
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
VKCallback<VKAccessToken> callback = new VKCallback<VKAccessToken>() {
@Override
public void onResult(VKAccessToken res) {
// User passed Authorization
startTestActivity();
}
@Override
public void onError(VKError error) {
// User didn't pass Authorization
}
};
if (!VKSdk.onActivityResult(requestCode, resultCode, data, callback)) {
super.onActivityResult(requestCode, resultCode, data);
}
}