VKCOM / vkid-android-sdk

MIT License
28 stars 3 forks source link

how to use java #36

Closed vivian688 closed 2 months ago

vivian688 commented 2 months ago

I just need to access vk id authorization,and the version I accessed is 2.1.0: implementation 'com.vk.id:vk-sdk-support:2.1.0'

How to call a method through java code?

20240816170922 20240816170958 20240816171042

I would be grateful if you could give me some Java code examples.

diklimchuk commented 2 months ago

Hi! Here's an example of calling authorize:

public class Tmp extends AppCompatActivity {
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        VKID.Companion.getInstance().authorize(this, new VKIDAuthCallback() {
            @Override
            public void onAuth(@NonNull AccessToken accessToken) {

            }

            @Override
            public void onFail(@NonNull VKIDAuthFail fail) {

            }

            @Override
            public void onAuthCode(@NonNull AuthCodeData data, boolean isCompletion) {
            }
        }, new VKIDAuthParams.Builder().build());
    }
}

Please let me know if you need any other code samples.

vivian688 commented 2 months ago

Hi! Here's an example of calling authorize:

public class Tmp extends AppCompatActivity {
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        VKID.Companion.getInstance().authorize(this, new VKIDAuthCallback() {
            @Override
            public void onAuth(@NonNull AccessToken accessToken) {

            }

            @Override
            public void onFail(@NonNull VKIDAuthFail fail) {

            }

            @Override
            public void onAuthCode(@NonNull AuthCodeData data, boolean isCompletion) {
            }
        }, new VKIDAuthParams.Builder().build());
    }
}

Please let me know if you need any other code samples.

thanks