VK authentication library for Android.
- Much more lightweight than Official SDK;
- much better designed (no static Context, no
registerObject()
and such things); - we'd accept issues and PRs (official SDK are not).
- authentication via official app and WebView (if no app or if you choose to do so)
- Working with Activities, Fragments, and v4 Fragments
- CAPTCHA and verification support
Sample usage from Activity:
public final class AuthActivity extends AppCompatActivity
implements View.OnClickListener, VkApp.VkAuthCallback, VkApp.VkAuthCallbackProvider {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auth);
findViewById(R.id.authButton).setOnClickListener(this);
}
@Override
public void onClick(View v) {
VkApp
.getInstance(BuildConfig.VK_APP_ID)
.login(this, EnumSet.noneOf(VkScope.class), AuthenticationWay.Auto, getSupportFragmentManager());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!VkApp.getInstance(BuildConfig.VK_APP_ID).onActivityResult(requestCode, resultCode, data, this)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public VkApp.VkAuthCallback getVkAuthCallback() {
return this;
}
@Override
public void onResult(VkAccessToken token) {
// success!
}
@Override
public void onError() {
// sadness...
}
}