Answer the question
In order to leave comments, you need to log in
A bug in the VK SDK itself or specifically mine when authorizing in the Android application?
In my Android application, it is possible to log into your account fromvk.com
. To do this, the SDK has an authorization method that even contains markup and, in fact, takes over all the work. I implemented authorization, in fact everything works, but there is one bug and I don’t know if it’s my flaw or a bug in the SDK itself. If you carry out authorization without having data on your VK account on your phone (manually enter your login and password in the window), then everything works fine. But if the application from VK is installed and it stores data about the user, then you do not need to enter a login / password, but simply press the allow button and that's fine. But there is one thing - when you click on this button, the authorization window simply restarts. The same will happen if you press the cancel button or even the phone back. As a result, the application simply gets stuck on this window. If you close the application and open, then the user will already be authorized (authorization worked the first time). What could be the problem with this and how can I fix this stuck authorization window? The code for the authorization fragment, just in case, is below.
public class VkAuthorizationFragment extends Fragment {
private String[] scope = new String[]{
VKScope.AUDIO,
VKScope.MESSAGES,
VKScope.FRIENDS,
VKScope.WALL
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.d(VkAuthorizationFragment.class.getSimpleName(), "onCreateView");
return inflater.inflate(R.layout.fragment_vk_authorization, container, false);
}
@Override
public void onStart() {
super.onStart();
Log.d(VkAuthorizationFragment.class.getSimpleName(), "onStart");
VKSdk.login(getActivity(), scope);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(VkAuthorizationFragment.class.getSimpleName(), "onActivityResult");
if (!VKSdk.onActivityResult(requestCode, resultCode, data, new VKCallback<VKAccessToken>() {
@Override
public void onResult(VKAccessToken res) {
Log.d(VkAuthorizationFragment.class.getSimpleName(),
"onResult: User successfully logged");
MainActivity mainActivity = (MainActivity) getActivity();
mainActivity.setUserAvatar();
mainActivity.setUserName();
}
@Override
public void onError(VKError error) {
Log.d(VkAuthorizationFragment.class.getSimpleName(),
"onResult: An authorization error");
}
})) {
super.onActivityResult(requestCode, resultCode, data);
}
}
}
Answer the question
In order to leave comments, you need to log in
I think the problem is in this method:
@Override
public void onStart() {
super.onStart();
Log.d(VkAuthorizationFragment.class.getSimpleName(), "onStart");
VKSdk.login(getActivity(), scope);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question