以编程方式撤消facebook的应用程序权限

时间:2016-07-25 06:41:03

标签: android permissions facebook-sdk-4.0

我正在开发一个Android应用程序,它在特定活动中截取屏幕截图并在Facebook上为用户发布(FacebookSDK)。

第一次,它询问用户权限,要求登录并指定视图(Public,Friends ..等)。当下次再次调用该活动时,它表示像"您已经授权App"然后单击确定后直接发布图片。

问题是:

  1. 图片正在张贴为上一篇文章的第二张图片。我打算将其作为独立的第二篇文章发布。
  2. 第二次没有询问任何权限或视图。我打算要求获得许可,并且每次发帖都要查看。
  3. 请帮忙。

    代码:

                FacebookSdk.sdkInitialize(getApplicationContext());
                callbackManager = CallbackManager.Factory.create();
                List<String> permissionNeeds = Arrays.asList("publish_actions");
    
                //this loginManager helps you eliminate adding a LoginButton to your UI
                manager = LoginManager.getInstance();
                manager.logInWithPublishPermissions(this, permissionNeeds);
                manager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
                    @Override
                    public void onSuccess(LoginResult loginResult) {
                        shareOnFacebook();
                    }
                    @Override
                    public void onCancel() {
                        Toast.makeText(HallOfFame.this, "Cancelled",Toast.LENGTH_LONG).show();
                    }
                    @Override
                    public void onError(FacebookException exception) {
                        Toast.makeText(HallOfFame.this, "Error Occurred",Toast.LENGTH_LONG).show();
                    }
                });
                return true;
    

    方法shareOnFacebook:

    // Take Screenshot
        View rootView = findViewById(android.R.id.content).getRootView();;
        rootView.setDrawingCacheEnabled(true);
        Bitmap bitmap = Bitmap.createBitmap(rootView.getDrawingCache());
        //**Bitmap bitmap = rootView.getDrawingCache();
        rootView.setDrawingCacheEnabled(false);
    
        SharePhoto photo = new SharePhoto.Builder()
                .setBitmap(bitmap)
                .setCaption("Hey Guys..! Checkout my Awesome Pic.")
                .build();
    
        SharePhotoContent content = new SharePhotoContent.Builder()
                .addPhoto(photo)
                .build();
    
        ShareApi.share(content, null);
        manager.logOut();
        //        this.finish();
        //        this.onDestroy();
        //        FacebookSdk.clearLoggingBehaviors();
    

0 个答案:

没有答案