A
A
AlexKrsk2017-05-26 19:27:49
Java
AlexKrsk, 2017-05-26 19:27:49

VKSDK not displaying query result?

Everything seems to be connected correctly.
I make any request from the documentation and try to display System.out.println(response.toString())
gives something like - [email protected]
authorization in the application passes. in any case, a window appears with the permission of the rights and after clicking on the "allow" button disappears.
in gredel added - 'compile 'com.vk:androidsdk:1.6.5'
to the manifest - and a line in application - android:name=".Application"
QUESTION: why is a request like *[email protected] 534ea208 instead of information from VK?
below is the whole code...

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.vk.sdk.VKAccessToken;
import com.vk.sdk.VKCallback;
import com.vk.sdk.VKScope;
import com.vk.sdk.VKSdk;
import com.vk.sdk.api.VKError;
import com.vk.sdk.api.VKParameters;
import com.vk.sdk.api.VKRequest;
import com.vk.sdk.api.VKResponse;
import com.vk.sdk.api.methods.VKApiGroups;

public class MainActivity extends Activity {

    private String log = "Log - ";
    private String[] scope = new String[]{VKScope.MESSAGES, VKScope.FRIENDS, VKScope.WALL};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        VKSdk.login(this, scope);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (!VKSdk.onActivityResult(requestCode, resultCode, data, new VKCallback<VKAccessToken>() {
            @Override
            public void onResult(VKAccessToken res) {
                Log.d(log , " Oki");
                VKRequest request = new VKApiGroups().getById(VKParameters.from("group_ids","club147546053"));
                request.executeWithListener(new VKRequest.VKRequestListener() {
                    @Override
                    public void onComplete(VKResponse response) {
                        super.onComplete(response);
                        System.out.println(response.toString());
                    }
                });
            }

            @Override
            public void onError(VKError error) {
                Log.d(log, "error");
            }
        })){
            super.onActivityResult(requestCode, resultCode, data);
        }
    }
}

import android.content.Intent;
import android.support.annotation.Nullable;

import com.vk.sdk.VKAccessToken;
import com.vk.sdk.VKAccessTokenTracker;
import com.vk.sdk.VKSdk;

public class Application extends android.app.Application {

    VKAccessTokenTracker vkAccessTokenTracker = new VKAccessTokenTracker() {
        @Override
        public void onVKAccessTokenChanged(@Nullable VKAccessToken oldToken, @Nullable VKAccessToken newToken) {
            if (newToken == null){
                Intent intent = new Intent(Application.this, MainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        }
    };

    @Override
    public void onCreate() {
        super.onCreate();
        vkAccessTokenTracker.startTracking();
        VKSdk.initialize(this);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2017-05-27
@AlexKrsk

Because this class does not override the toString method. See the documentation for what meaningful methods this class has, call them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question