Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.myapp;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.View;
- import android.widget.Button;
- import com.vk.sdk.*;
- import com.vk.sdk.api.*;
- public class MyActivity extends Activity{
- private static String[] sMyScope = new String[]{VKScope.FRIENDS, VKScope.WALL, VKScope.PHOTOS, VKScope.NOHTTPS};
- private static String appID="4596510";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- VKSdk.initialize(new VKSdkListener() {
- @Override
- public void onCaptchaError(VKError captchaError) {
- }
- @Override
- public void onTokenExpired(VKAccessToken expiredToken) {
- }
- @Override
- public void onAccessDenied(VKError authorizationError) {
- }
- },appID);
- Button button = (Button) findViewById(R.id.button);
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- VKSdk.authorize(sMyScope,true,false);
- VKRequest request = VKApi.wall().post(VKParameters.from(VKApiConst.OWNER_ID, "-60479154", VKApiConst.MESSAGE, "Привет, друзья!"));
- request.attempts = 10;
- request.executeWithListener(new VKRequest.VKRequestListener() {
- @Override
- public void onComplete(VKResponse response) {
- }
- @Override
- public void onError(VKError error) {
- Log.e("Log", String.valueOf(error.VK_API_ERROR+" "+error.apiError+" "+error.httpError));
- }
- @Override
- public void attemptFailed(VKRequest request, int attemptNumber, int totalAttempts) {
- }
- });
- }
- });
- }
- @Override
- protected void onResume() {
- super.onResume();
- VKUIHelper.onResume(MyActivity.this);
- }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- VKUIHelper.onDestroy(MyActivity.this);
- }
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- VKUIHelper.onActivityResult(MyActivity.this,requestCode,resultCode,data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement