Skip to main content

Android SDK with vk

Android SDK
VK SDK allows you to authorize user without asking him to enter login/password. After that you can call any API methods.

Source code at GitHub 
Prepare for Using VK SDK
To use VK SDK primarily you need to create a new VK application here by choosing the Standalone application type. Choose a title and confirm the action via SMS and you will be redirected to the application settings page.
You will require your Application ID (referenced as API_ID in the documentation). Fill in the "Batch name for Android", "Main Activity for Android" and "Certificate fingerprint for Android".
Certificate Fingerprint Receiving
To receive your certificate's fingerprint you can use one of the following methods.

Fingerprint Receiving via Keytool
1) You need to find the keystore location for your app. The debug store is usually located in these directories:
  • ~/.android/ for OS X and Linux,
  • C:\Documents and Settings\\.android\ for Windows XP,
  • C:\Users\\.android\ for Windows Vista, Windows 7 and Windows 8.

The keystore for the release version is usually created by a programmer, so you should create it or recall its location.
2) After the keystore's location has been found, use keytool utilite (it is supplied with the Java SDK). You can get keys list with the following command:
keytool -exportcert -alias androiddebugkey -keystore path-to-debug-or-production-keystore -list -v

You will observe a similar result:
Certificate fingerprint: SHA1: DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09

By deleting all the colons you'll get your key's fingerprint.

Fingerprint Receiveing via SDK
If you've already added SDK to your project, you can use the following function in each Activity of your app.
String[] fingerprints = VKUtil.getCertificateFingerprint(this, this.getPackageName()); 

As a rule, fingerprint contains a single line. It's a fingerprint of your certificate (depends on the certificate used for your app's signing)

You can add more than one fingerprint in your app settings, e.g., debug and release fingerprints.
Connecting VK SDK to Your Android Application
Connecting With Maven
You can add next maven dependency in your project:

Connecting in Android Studio
We give preference to Android Studio and our platform is targeted firstly to this enviroment.

Connecting Using Gradle
You can add the library to your project using Gradle.
1) Copy the vksdk_library directory to your project's directory.
2) Find the settings.gradle file.

Most likely, it contains something like that:
include ':app'

Edit the line this way:
include ':vksdk_library',':app'

3)Now your project includes vksdk_library module. You need to add it like a dependency to your app. Find the build.gradle file in the subdirectory of your app's module (e.g., YOUR_PROJECT/app/build.gradle).

Add this line to the dependencies.
compile project(':vksdk_library')

Your file can be like that:

Connecting Without Gradle
If your project doesn't support Gradle, you can add SDK by the following way:
  1. Open Project Settings and select Modules.
  2. Click the Add (+) button and select Import module
  3. Find the directory with VK SDK and select vksdk_library, click Add.
  4. Select Create module from existing sources, then click Next two times. Rename the module from "main" to "vksdk", then click Next.
  5. Add the new vksdk module as a dependency to your app's module.

Connecting Using Eclipse
  1. In Package explorer click right mouse button, then click Import.
  2. Select Android/Existing android code into workspace.
  3. Find a folder with SDK, select vksdk_library.
  4. In Properties of your app go to Android, add vksdk_library in the library section.

Editing AndroidManifest.xml
Your need to add to your manifest the following elements:
1) in the root of you need to add permission

2) in the element shoud be added

to avoid possible problems with running authorizing activity.
Using SDK
SDK Initialization
1) Add this to the resources file (example strings.xml)

2) Initialize the SDK on startup using the following method. The best way is to call it in the app's onCreate method.
VKSdk.initialize(Context applicationContext);

User Authorization
There are several authorization methods:
VkSdk.login(Activity runningActivity, String... scope);
VkSdk.login(Fragment runningFragment, String... scope); 

When succeeded call the onActivityResultMethod:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (!VKSdk.onActivityResult(requestCode, resultCode, data, new VKCallback() {
        public void onResult(VKAccessToken res) {
            // User passed Authorization
        public void onError(VKError error) {
            // User didn't pass Authorization
    })) {
        super.onActivityResult(requestCode, resultCode, data);
Handling "AccessToken invalid"
Use AccessTokenTracker the following way:
public class Application extends {
    VkAccessTokenTracker vkAccessTokenTracker = new VkAccessTokenTracker() {
        public void onVKAccessTokenChanged(VKAccessToken oldToken, VKAccessToken newToken) {
            if (newToken == null) {
                // VkAccessToken is invalid
    public void onCreate() {
API Requests
Requests Syntax
1) Plain request.
VKRequest request = VKApi.users().get();

2) Request with parameters.
VKRequest request = VKApi.users().get(VKParameters.from(VKApiConst.USER_IDS, "1,2"));

3) Http (not https) request (only if scope VK_PER_NOHTTPS has been passed).
VKRequest request = VKApi.users().get(VKParameters.from(VKApiConst.USER_IDS, "1,2")); = NO;

4) Request with predetermined maximum number of attempts.
VKRequest request = VKApi.wall().post(VKParameters.from(VKApiConst.OWNER_ID, "-60479154", VKApiConst.MESSAGE, "Привет, друзья!"));
request.attempts = 10;
//or infinite
//postReq.attempts = 0;

It will take 10 attempts until succeeds or an API error occurs.

5) Request that calls a method of VK API.
VKRequest request = new VKRequest("friends.get", VKParameters.from(VKApiConst.FIELDS, "sex,bdate,city"));

6) Request for uploading photos on user wall.

final Bitmap photo = getPhoto();
VKRequest request = VKApi.uploadWallPhotoRequest(new VKUploadImage(photo, VKImageParameters.jpgImage(0.9f)), 0, 60479154);

Requests Sending

request.executeWithListener(new VKRequestListener() {
    public void onComplete(VKResponse response) {
        //Do complete stuff
    public void onError(VKError error) {
        //Do error stuff
    public void attemptFailed(VKRequest request, int attemptNumber, int totalAttempts) {
        //I don't really believe in progress

Errors Handling
The VKError class contains the errorCode property. Compare its value with the global constant VKError.VK_API_ERROR. If it equals, process the apiError field that contains a description of a VK API error. Otherwise you should handle an http error in the httpError property.
Some errors (e.g., captcha error, validation error) can be proccessed by the SDK.

Batch Processing Requests
SDK gives a feature to execute several unrelated requests at the one call.
1) Prepare requests.

VKRequest request1 = VKApi.uploadWallPhotoRequest(new VKUploadImage(photo1, VKImageParameters.jpgImage(0.9f)), 0, 60479154);
VKRequest request2 = VKApi.uploadWallPhotoRequest(new VKUploadImage(photo2, VKImageParameters.jpgImage(0.5f)), 0, 60479154);
VKRequest request3 = VKApi.uploadWallPhotoRequest(new VKUploadImage(photo3, VKImageParameters.jpgImage(0.1f)), 0, 60479154);
VKRequest request4 = VKApi.uploadWallPhotoRequest(new VKUploadImage(photo4, VKImageParameters.pngImage()), 0, 60479154);

2) Combine created requests into one.
VKBatchRequest batch = new VKBatchRequest(request1, request2, request3, request4);

3) Load the obtained request.
batch.executeWithListener(new VKBatchRequestListener() {
                        public void onComplete(VKResponse[] responses) {
                            String[] photos = new String[responses.length];
                            for (int i = 0; i < responses.length; i++) {
                                VKPhoto photoModel = ((VKPhotoArray) responses[i].parsedModel).get(0);
                                photos[i] = String.format("photo%s_%s", photoModel.owner_id,;
                            makePost(VKStringJoiner.join(photos, ","));
                        public void onError(VKError error) {

4) The result of each method returns to a corresponding requestListener. The batch VKResponse for each request in order they have been passed.

Popular posts from this blog

Hidden Wiki

Welcome to The Hidden WikiNew hidden wiki url 2015 http://zqktlwi4fecvo6ri.onion Add it to bookmarks and spread it!!!
Editor's picks Bored? Pick a random page from the article index and replace one of these slots with it.
The Matrix - Very nice to read. How to Exit the Matrix - Learn how to Protect yourself and your rights, online and off. Verifying PGP signatures - A short and simple how-to guide. In Praise Of Hawala - Anonymous informal value transfer system. Volunteer Here are five different things that you can help us out with.
Plunder other hidden service lists for links and place them here! File the SnapBBSIndex links wherever they go. Set external links to HTTPS where available, good certificate, and same content. Care to start recording onionland's history? Check out Onionland's Museum Perform Dead Services Duties. Introduction - Clearnet search engine for Tor Hidden Services (allows you to add new sites to its database). DuckDuckGo - A Hidden S…


Good News [May 08, 2015]: IDM developers got smarter, but the crackers are always a step ahead. Follow this article and send an email to if you are desperate. I can NOT post any crack here for legal reasons. Happy Downloading with IDM. ;) *********** first tip is to use latest crack for idm from idm universal web crack and make sure u are using all latest vers I am sure many of us are too much dependent on Internet Download Manager a.k.a. IDM. The main reason didn’t permanently switch to linux was IDM. I mainly use it for batch downloading and download streaming videos. Till yesterday, IDM was working fine with me (of course with fake serial numbers, keygen, crack, patch etc. which could be found with little effort). But few days ago, with the latest update version 6.18 build 7 (released on Nov 09, 2013) Internet Download Manager was literally had a breakthrough and crushed all the serial numbers, …

Mouse, touchpad, and keyboard problems in Windows

Mouse, touchpad, and keyboard problems in Windows Introduction This tutorial is designed to help you identify and fix common mouse, touchpad, and keyboard problems in Windows. It doesn't cover device problems related to specific programs. Mouse, touchpad, and keyboard problems can have a number of causes: Cables that aren't connected properly Incorrect device settings Missing updates Corrupted or incompatible drivers Hardware problems Check hardware Many mouse, touchpad, and keyboard problems are caused by hardware that isn't set up properly. Here's some information about how to check your device, make sure cables are connected properly, make sure the hardware has power, and check the settings. Make sure cables are connected properly Check that all cables are plugged in to the correct locations. This can include mouse and keyboard, PS2 and USB cables, and, in some cases, external USB touchpad cables. Disconnect USB cables and wait for a short time for the device drive…